
//-------------------------------------------------------------------------
//   Copyright 2002-2023 National Technology & Engineering Solutions of
//   Sandia, LLC (NTESS).  Under the terms of Contract DE-NA0003525 with
//   NTESS, the U.S. Government retains certain rights in this software.
//
//   This file is part of the Xyce(TM) Parallel Electrical Simulator.
//
//   Xyce(TM) is free software: you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation, either version 3 of the License, or
//   (at your option) any later version.
//
//   Xyce(TM) is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with Xyce(TM).
//   If not, see <http://www.gnu.org/licenses/>.
//-------------------------------------------------------------------------


//-------------------------------------------------------------------------
//
// Purpose        :
//
// Special Notes  : Generated from verilog file ekv26_SDext_Verilog-A.va with ADMS
//                  interface for Xyce 7.7.0
//                  DO NOT EDIT THIS FILE DIRECTLY!  It may be overwritten!
//
// Creator        : admsXml-2.3.7
//
// Creation Date  : Mon, 09 Jan 2023 12:53:25
//
//-------------------------------------------------------------------------
// Shut up clang's warnings about extraneous parentheses
#ifdef __clang__
#  pragma clang diagnostic ignored "-Wparentheses-equality"
#endif

#include <Xyce_config.h>
#include <N_DEV_ADMSekv_va.h>


#include <N_DEV_Const.h>
#include <N_DEV_DeviceOptions.h>
#include <N_DEV_DeviceMaster.h>
#include <N_DEV_ExternData.h>
#include <N_DEV_SolverState.h>
#include <N_DEV_Message.h>

#include <N_LAS_Matrix.h>
#include <N_LAS_Vector.h>

  #include <N_ANP_NoiseData.h>

#include <N_UTL_FeatureTest.h>
#include <unordered_map>
using std::unordered_map;

#include <algorithm>

// Xyce_config.h contains a VERSION macro from autoconf, and some
// Verilog-A models like to define a variable of that name.  This can be
// a serious problem, and we don't need the VERSION macro.  Get rid of it.
// This must happen *after* all includes of Xyce headers, each of which
// includes Xyce_config.h!
#ifdef VERSION
#undef VERSION
#endif

namespace Xyce {
namespace Device {
namespace ADMSekv_va {
JacobianStamp Instance::jacStamp;
IdVector Instance::nodeMap;
PairMap Instance::pairToJacStampMap;


//This is necessary because the IntPair usage can trip undefined references
    const int Instance::admsNodeID_d;
    const int Instance::admsNodeID_g;
    const int Instance::admsNodeID_s;
    const int Instance::admsNodeID_b;
     const int Instance::admsNodeID_GND;
   // Additional IDs for branch equations


void
Traits::loadInstanceParameters(ParametricData<ADMSekv_va::Instance> &p)
{
  // Set up each parameter directly, using the up-cased variable name
  // as the tag.

  // This kludge is to force us always to have an instance parameter
  // that the device manager can set to the temperature, even if we have
  // no "TEMP".
  p.addPar("XYCEADMSINSTTEMP", 0.0, &ADMSekv_va::Instance::admsInstTemp)
    .setExpressionAccess(NO_DOC)
    .setUnit(U_DEGK)
    .setCategory(CAT_TEMP)
    .setDescription("Internal-use parameter for setting device instance temperature");
  p.addPar("L", static_cast<double>(10E-6), &ADMSekv_va::Instance::L)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&instSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("W", static_cast<double>(10E-6), &ADMSekv_va::Instance::W)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&instSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("M", static_cast<double>(1.0), &ADMSekv_va::Instance::M)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&instSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("NS", static_cast<double>(1.0), &ADMSekv_va::Instance::NS)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&instSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("AS", static_cast<double>(0.0), &ADMSekv_va::Instance::AS)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&instSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("AD", static_cast<double>(0.0), &ADMSekv_va::Instance::AD)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&instSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("PS", static_cast<double>(0.0), &ADMSekv_va::Instance::PS)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&instSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("PD", static_cast<double>(0.0), &ADMSekv_va::Instance::PD)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&instSens)
#endif // Xyce_ADMS_SENSITIVITIES
;


}

void Traits::loadModelParameters(ParametricData<ADMSekv_va::Model> &p)
{
  // Set up each parameter directly, using the up-cased variable name
  // as the tag.

  // This kludge is to force us always to have a model parameter
  // that the device manager can set to the temperature, even if we have
  // no "TEMP".
  p.addPar("XYCEADMSMODTEMP", 0.0, &ADMSekv_va::Model::admsModTemp)
    .setExpressionAccess(NO_DOC)
    .setUnit(U_DEGK)
    .setCategory(CAT_TEMP)
    .setDescription("Internal-use parameter for setting device model temperature");
  p.addPar("TYPE", static_cast<int>(1), &ADMSekv_va::Model::TYPE);
  p.addPar("NOISE", static_cast<int>(1), &ADMSekv_va::Model::Noise);
  p.addPar("TRISE", static_cast<double>(0.0), &ADMSekv_va::Model::Trise)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TEMP", static_cast<double>(1.0e21), &ADMSekv_va::Model::TEMP)
   .setAutoConvertTemperature(false)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TNOM", static_cast<double>(1.0e21), &ADMSekv_va::Model::TNOM)
   .setAutoConvertTemperature(false)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("L", static_cast<double>(10E-6), &ADMSekv_va::Model::L)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("W", static_cast<double>(10E-6), &ADMSekv_va::Model::W)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("M", static_cast<double>(1.0), &ADMSekv_va::Model::M)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("NS", static_cast<double>(1.0), &ADMSekv_va::Model::NS)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("AS", static_cast<double>(0.0), &ADMSekv_va::Model::AS)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("AD", static_cast<double>(0.0), &ADMSekv_va::Model::AD)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("PS", static_cast<double>(0.0), &ADMSekv_va::Model::PS)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("PD", static_cast<double>(0.0), &ADMSekv_va::Model::PD)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("COX", static_cast<double>(2.0E-3), &ADMSekv_va::Model::COX)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XJ", static_cast<double>(300E-9), &ADMSekv_va::Model::XJ)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("VTO", static_cast<double>(0.5), &ADMSekv_va::Model::VTO)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TCV", static_cast<double>(1.0e-3), &ADMSekv_va::Model::TCV)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("GAMMA", static_cast<double>(0.7), &ADMSekv_va::Model::GAMMA)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("PHI", static_cast<double>(0.5), &ADMSekv_va::Model::PHI)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("KP", static_cast<double>(150E-6), &ADMSekv_va::Model::KP)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("BEX", static_cast<double>((-1.5)), &ADMSekv_va::Model::BEX)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("THETA", static_cast<double>(0.0), &ADMSekv_va::Model::THETA)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("E0", static_cast<double>(1.0E8), &ADMSekv_va::Model::E0)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("UCRIT", static_cast<double>(2.0E6), &ADMSekv_va::Model::UCRIT)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("UCEX", static_cast<double>(0.8), &ADMSekv_va::Model::UCEX)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("LAMBDA", static_cast<double>(0.8), &ADMSekv_va::Model::LAMBDA)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("DL", static_cast<double>((-0.01E-6)), &ADMSekv_va::Model::DL)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("DW", static_cast<double>((-0.01E-6)), &ADMSekv_va::Model::DW)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("WETA", static_cast<double>(0.2), &ADMSekv_va::Model::WETA)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("LETA", static_cast<double>(0.3), &ADMSekv_va::Model::LETA)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("Q0", static_cast<double>(230E-6), &ADMSekv_va::Model::Q0)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("LK", static_cast<double>(0.4E-6), &ADMSekv_va::Model::LK)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("IBA", static_cast<double>(5.0E8), &ADMSekv_va::Model::IBA)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("IBB", static_cast<double>(4.0E8), &ADMSekv_va::Model::IBB)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("IBBT", static_cast<double>(9.0e-4), &ADMSekv_va::Model::IBBT)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("IBN", static_cast<double>(1.0), &ADMSekv_va::Model::IBN)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("RSH", static_cast<double>(0.0), &ADMSekv_va::Model::RSH)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("HDIF", static_cast<double>(0.5E-6), &ADMSekv_va::Model::HDIF)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("AVTO", static_cast<double>(1E-6), &ADMSekv_va::Model::AVTO)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("AKP", static_cast<double>(1E-6), &ADMSekv_va::Model::AKP)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("AGAMMA", static_cast<double>(1E-6), &ADMSekv_va::Model::AGAMMA)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("AF", static_cast<double>(1.0), &ADMSekv_va::Model::AF)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("KF", static_cast<double>(0.0), &ADMSekv_va::Model::KF)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_N", static_cast<double>(1.0), &ADMSekv_va::Model::xd_n)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_JS", static_cast<double>(1.0E-09), &ADMSekv_va::Model::xd_js)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_JSW", static_cast<double>(1.0E-12), &ADMSekv_va::Model::xd_jsw)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_JSWG", static_cast<double>(1.0E-12), &ADMSekv_va::Model::xd_jswg)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_MJ", static_cast<double>(0.900), &ADMSekv_va::Model::xd_mj)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_MJSW", static_cast<double>(0.700), &ADMSekv_va::Model::xd_mjsw)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_MJSWG", static_cast<double>(0.700), &ADMSekv_va::Model::xd_mjswg)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_PB", static_cast<double>(0.800), &ADMSekv_va::Model::xd_pb)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_PBSW", static_cast<double>(0.600), &ADMSekv_va::Model::xd_pbsw)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_PBSWG", static_cast<double>(0.600), &ADMSekv_va::Model::xd_pbswg)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_CJ", static_cast<double>(1.0E-09), &ADMSekv_va::Model::xd_cj)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_CJSW", static_cast<double>(1.0E-12), &ADMSekv_va::Model::xd_cjsw)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_CJSWG", static_cast<double>(1.0E-12), &ADMSekv_va::Model::xd_cjswg)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_GMIN", static_cast<double>(0.0), &ADMSekv_va::Model::xd_gmin)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_XJBV", static_cast<double>(0.0), &ADMSekv_va::Model::xd_xjbv)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_BV", static_cast<double>(10.0), &ADMSekv_va::Model::xd_bv)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_NJTS", static_cast<double>(1.0), &ADMSekv_va::Model::xd_njts)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_NJTSSW", static_cast<double>(1.0), &ADMSekv_va::Model::xd_njtssw)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_NJTSSWG", static_cast<double>(1.0), &ADMSekv_va::Model::xd_njtsswg)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_VTS", static_cast<double>(0.0), &ADMSekv_va::Model::xd_vts)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_VTSSW", static_cast<double>(0.0), &ADMSekv_va::Model::xd_vtssw)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("XD_VTSSWG", static_cast<double>(0.0), &ADMSekv_va::Model::xd_vtsswg)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TP_XTI", static_cast<double>(3.0), &ADMSekv_va::Model::tp_xti)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TP_CJ", static_cast<double>(0.0), &ADMSekv_va::Model::tp_cj)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TP_CJSW", static_cast<double>(0.0), &ADMSekv_va::Model::tp_cjsw)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TP_CJSWG", static_cast<double>(0.0), &ADMSekv_va::Model::tp_cjswg)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TP_PB", static_cast<double>(0.0), &ADMSekv_va::Model::tp_pb)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TP_PBSW", static_cast<double>(0.0), &ADMSekv_va::Model::tp_pbsw)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TP_PBSWG", static_cast<double>(0.0), &ADMSekv_va::Model::tp_pbswg)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TP_NJTS", static_cast<double>(0.0), &ADMSekv_va::Model::tp_njts)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TP_NJTSSW", static_cast<double>(0.0), &ADMSekv_va::Model::tp_njtssw)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("TP_NJTSSWG", static_cast<double>(0.0), &ADMSekv_va::Model::tp_njtsswg)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("LMIN", static_cast<double>(0), &ADMSekv_va::Model::LMIN)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("LMAX", static_cast<double>(100), &ADMSekv_va::Model::LMAX)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("WMIN", static_cast<double>(0), &ADMSekv_va::Model::WMIN)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;
  p.addPar("WMAX", static_cast<double>(100), &ADMSekv_va::Model::WMAX)
#ifdef Xyce_ADMS_SENSITIVITIES
    .setAnalyticSensitivityAvailable(true)
    .setSensitivityFunctor(&modSens)
#endif // Xyce_ADMS_SENSITIVITIES
;

}

//-----------------------------------------------------------------------------
// Function      : Instance::processParams
// Purpose       :
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
bool Instance::processParams()
{
  // set any non-constant parameter defaults

  // copy any model variables that have associated instance variables, but
  // are only given in the model card:
   if (!(given("L")))
   {
      L = model_.L;
   }
   if (!(given("W")))
   {
      W = model_.W;
   }
   if (!(given("M")))
   {
      M = model_.M;
   }
   if (!(given("NS")))
   {
      NS = model_.NS;
   }
   if (!(given("AS")))
   {
      AS = model_.AS;
   }
   if (!(given("AD")))
   {
      AD = model_.AD;
   }
   if (!(given("PS")))
   {
      PS = model_.PS;
   }
   if (!(given("PD")))
   {
      PD = model_.PD;
   }



  // Set any parameters that were not given and whose defaults depend on other
  // parameters:


// Now we need to check that any parameters are within their ranges as
  // specified in the verilog:

//    Parameter L : [ 0.0,  (+inf) [
  if ( (!((L >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter L value " << L << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter W : [ 0.0,  (+inf) [
  if ( (!((W >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter W value " << W << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter M : [ 0.0,  (+inf) [
  if ( (!((M >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter M value " << M << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter NS : [ 0.0,  (+inf) [
  if ( (!((NS >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter NS value " << NS << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter AS : [ 0.0,  (+inf) [
  if ( (!((AS >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter AS value " << AS << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter AD : [ 0.0,  (+inf) [
  if ( (!((AD >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter AD value " << AD << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter PS : [ 0.0,  (+inf) [
  if ( (!((PS >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter PS value " << PS << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter PD : [ 0.0,  (+inf) [
  if ( (!((PD >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter PD value " << PD << " out of range [ 0.0,  (+inf) [";
  }


  // this seems a little stupid, but verilog models that use $temperature
  // don't also use a defined parameter "Temp", and count on $temperature
  // to be the one the simulator wants:

  updateTemperature(admsInstTemp);

  // and of course, this routine is where we should put the initial_instance
  // stuff


  return true;
}

//-----------------------------------------------------------------------------
// Function      : Instance::Instance
// Purpose       : "instance block" constructor
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------

Instance::Instance(
  const Configuration & configuration,
  const InstanceBlock & instance_block,
  Model &               model,
  const FactoryBlock &  factory_block)
  : DeviceInstance(instance_block, configuration.getInstanceParameters(), factory_block),
    model_(model),
    L(10E-6),
    W(10E-6),
    M(1.0),
    NS(1.0),
    AS(0.0),
    AD(0.0),
    PS(0.0),
    PD(0.0),
    li_d(-1),
    li_g(-1),
    li_s(-1),
    li_b(-1),
    li_branch_id(-1),
    li_branch_ig(-1),
    li_branch_is(-1),
    li_branch_ib(-1),
    f_d_Equ_s_Node_Ptr(0),
    f_d_Equ_b_Node_Ptr(0),
    f_s_Equ_s_Node_Ptr(0),
    f_s_Equ_b_Node_Ptr(0),
    f_d_Equ_d_Node_Ptr(0),
    f_s_Equ_d_Node_Ptr(0),
    f_d_Equ_g_Node_Ptr(0),
    f_s_Equ_g_Node_Ptr(0),
    f_b_Equ_g_Node_Ptr(0),
    f_b_Equ_b_Node_Ptr(0),
    f_b_Equ_s_Node_Ptr(0),
    f_b_Equ_d_Node_Ptr(0),
    f_g_Equ_g_Node_Ptr(0),
    f_g_Equ_b_Node_Ptr(0),
    f_g_Equ_s_Node_Ptr(0),
    f_g_Equ_d_Node_Ptr(0),
    q_d_Equ_s_Node_Ptr(0),
    q_d_Equ_b_Node_Ptr(0),
    q_s_Equ_s_Node_Ptr(0),
    q_s_Equ_b_Node_Ptr(0),
    q_d_Equ_d_Node_Ptr(0),
    q_s_Equ_d_Node_Ptr(0),
    q_d_Equ_g_Node_Ptr(0),
    q_s_Equ_g_Node_Ptr(0),
    q_b_Equ_g_Node_Ptr(0),
    q_b_Equ_b_Node_Ptr(0),
    q_b_Equ_s_Node_Ptr(0),
    q_b_Equ_d_Node_Ptr(0),
    q_g_Equ_g_Node_Ptr(0),
    q_g_Equ_b_Node_Ptr(0),
    q_g_Equ_s_Node_Ptr(0),
    q_g_Equ_d_Node_Ptr(0),
    A_d_Equ_s_NodeOffset(-1),
    A_d_Equ_b_NodeOffset(-1),
    A_s_Equ_s_NodeOffset(-1),
    A_s_Equ_b_NodeOffset(-1),
    A_d_Equ_d_NodeOffset(-1),
    A_s_Equ_d_NodeOffset(-1),
    A_d_Equ_g_NodeOffset(-1),
    A_s_Equ_g_NodeOffset(-1),
    A_b_Equ_g_NodeOffset(-1),
    A_b_Equ_b_NodeOffset(-1),
    A_b_Equ_s_NodeOffset(-1),
    A_b_Equ_d_NodeOffset(-1),
    A_g_Equ_g_NodeOffset(-1),
    A_g_Equ_b_NodeOffset(-1),
    A_g_Equ_s_NodeOffset(-1),
    A_g_Equ_d_NodeOffset(-1),
    admsTemperature(getDeviceOptions().temp.getImmutableValue<double>())

{
    numIntVars = 0 + 0;
    numExtVars = 4;

  // Right now, we only have store for limited probes and output vars...
  setNumStoreVars(0+0);

  // Do not allocate "branch" (lead current) vectors by default
  setNumBranchDataVars(0);
  numBranchDataVarsIfAllocated = 4;

  leadCurrentF.resize(4);
  leadCurrentQ.resize(4);

  // Set up jacobian stamp:
  // Create a vector of the non-zero elements of the stamp
PairVector jacobianElements;
    jacobianElements.push_back(IntPair(admsNodeID_d,admsNodeID_s));
    jacobianElements.push_back(IntPair(admsNodeID_d,admsNodeID_b));
    jacobianElements.push_back(IntPair(admsNodeID_d,admsNodeID_d));
    jacobianElements.push_back(IntPair(admsNodeID_d,admsNodeID_g));
    jacobianElements.push_back(IntPair(admsNodeID_g,admsNodeID_g));
    jacobianElements.push_back(IntPair(admsNodeID_g,admsNodeID_b));
    jacobianElements.push_back(IntPair(admsNodeID_g,admsNodeID_s));
    jacobianElements.push_back(IntPair(admsNodeID_g,admsNodeID_d));
    jacobianElements.push_back(IntPair(admsNodeID_s,admsNodeID_s));
    jacobianElements.push_back(IntPair(admsNodeID_s,admsNodeID_b));
    jacobianElements.push_back(IntPair(admsNodeID_s,admsNodeID_d));
    jacobianElements.push_back(IntPair(admsNodeID_s,admsNodeID_g));
    jacobianElements.push_back(IntPair(admsNodeID_b,admsNodeID_g));
    jacobianElements.push_back(IntPair(admsNodeID_b,admsNodeID_b));
    jacobianElements.push_back(IntPair(admsNodeID_b,admsNodeID_s));
    jacobianElements.push_back(IntPair(admsNodeID_b,admsNodeID_d));



  setDefaultParams();
  setParams(instance_block.params);

  // Real bogosity here...
  if (!given("XYCEADMSINSTTEMP"))
    admsInstTemp=getDeviceOptions().temp.getImmutableValue<double>();

  //calculate any parameters specified as expressions
  updateDependentParameters();

  // calculate dependent (i.e. computed params) and check for errors.
  processParams();

  PairVector collapsedNodes;

// Now generate the jacstamp from what we already have.
// This jacstamp will have all the correct node mapping.  map will be the nodal mapping of original
// node IDs to row/column ids in the reduced (non-sparse) representation of the jacobian.
// (for devices that have no collapsibles, this will be static, so check that it hasn't already
// been filled in)
if (jacStamp.empty())
{
int originalSize = 4+0;
computeJacStampAndMaps(jacobianElements,collapsedNodes,jacStamp,nodeMap,pairToJacStampMap,originalSize);
}

}

//-----------------------------------------------------------------------------
// Function      : Instance::~Instance
// Purpose       : destructor
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
Instance::~Instance()
{
}

//-----------------------------------------------------------------------------
// Function      : Instance::registerLIDs
// Purpose       : function for registering, and setting up, local IDs.
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
void Instance::registerLIDs( const LocalIdVector & intLIDVecRef,
                             const LocalIdVector & extLIDVecRef)
{
  AssertLIDs(intLIDVecRef.size() == numIntVars);
  AssertLIDs(extLIDVecRef.size() == numExtVars);

  LocalIdVector localLIDVec;

  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
  {
    Xyce::dout() << std::endl << section_divider << std::endl
                 << "In ADMSekv_va::Instance::register LIDs\n\n"
                 << "name             = " << getName() << std::endl
                 << "number of internal variables: " << numIntVars << std::endl
                 << "number of external variables: " << numExtVars << std::endl;
  }

  // copy over the global ID lists into a local array.
  // The end result of this is an array of LIDs corresponding to all the
  // nodes we actually have, in the order that topology thinks of them
  intLIDVec = intLIDVecRef;
  extLIDVec = extLIDVecRef;
  localLIDVec.resize(numExtVars+numIntVars);
  for (int localNodeIndex=0;localNodeIndex<numExtVars;++localNodeIndex)
  {
    localLIDVec[localNodeIndex]=extLIDVec[localNodeIndex];
  }
  for (int localNodeIndex=numExtVars;localNodeIndex<numExtVars+numIntVars;++localNodeIndex)
  {
    localLIDVec[localNodeIndex]=intLIDVec[localNodeIndex-numExtVars];
    }

  // Now pull the LIDs for each of our nodes out of the local array.
  // Use the node mapping created by createJacStampAndMaps to handle
  // all the node collapse complications.
  li_d = localLIDVec[nodeMap[admsNodeID_d]];
  li_g = localLIDVec[nodeMap[admsNodeID_g]];
  li_s = localLIDVec[nodeMap[admsNodeID_s]];
  li_b = localLIDVec[nodeMap[admsNodeID_b]];


  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
  {
    Xyce::dout() << "\nSolution and RHS variables:\n";
      Xyce::dout() << "\nli_d = " << li_d << std::endl;
      Xyce::dout() << "\nli_g = " << li_g << std::endl;
      Xyce::dout() << "\nli_s = " << li_s << std::endl;
      Xyce::dout() << "\nli_b = " << li_b << std::endl;

    Xyce::dout() << "\nEnd of ADMSekv_va::Instance::register LIDs\n";
    Xyce::dout() << section_divider << std::endl;
  }
}

//-----------------------------------------------------------------------------
// Function      : Instance::loadNodeSymbols
// Purpose       :
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
void Instance::loadNodeSymbols(Util::SymbolTable &symbol_table) const
{

  if (loadLeadCurrent)
  {
    addBranchDataNode( symbol_table, li_branch_id, getName(), "BRANCH_DD");
    addBranchDataNode( symbol_table, li_branch_ig, getName(), "BRANCH_DG");
    addBranchDataNode( symbol_table, li_branch_is, getName(), "BRANCH_DS");
    addBranchDataNode( symbol_table, li_branch_ib, getName(), "BRANCH_DB");


  }
}

//-----------------------------------------------------------------------------
// Function      : Instance::registerStoreLIDs
// Purpose       :
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
void Instance::registerStoreLIDs( const LocalIdVector & stoLIDVecRef)
{
  AssertLIDs(stoLIDVecRef.size() == getNumStoreVars());
}

//-----------------------------------------------------------------------------
// Function      : Instance::registerBranchDataLIDs
// Purpose       :
// Special Notes :
// Scope         : public
// Creator       : Eric Keiter, SNL
// Creation Date : 12/09/11
//-----------------------------------------------------------------------------
void Instance::registerBranchDataLIDs(const std::vector<int> & branchLIDVecRef)
{
  AssertLIDs(branchLIDVecRef.size() == getNumBranchDataVars());

  if (loadLeadCurrent)
  {
    int i = 0;
    li_branch_id = branchLIDVecRef[i++];
    li_branch_ig = branchLIDVecRef[i++];
    li_branch_is = branchLIDVecRef[i++];
    li_branch_ib = branchLIDVecRef[i++];

  }
}

//-----------------------------------------------------------------------------
// Function      : Instance::jacobianStamp
// Purpose       :
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
const JacobianStamp & Instance::jacobianStamp() const
{
    return jacStamp;
}

//-----------------------------------------------------------------------------
// Function      : Instance::registerJacLIDs
// Purpose       : Create Offset variables used for referencing jacobian
//                 elements
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
void Instance::registerJacLIDs( const JacobianStamp & jacLIDVec)
{
  DeviceInstance::registerJacLIDs(jacLIDVec);  IntPair jacLoc;
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_d,admsNodeID_s)];
    A_d_Equ_s_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_d,admsNodeID_b)];
    A_d_Equ_b_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_d,admsNodeID_d)];
    A_d_Equ_d_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_d,admsNodeID_g)];
    A_d_Equ_g_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_g,admsNodeID_g)];
    A_g_Equ_g_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_g,admsNodeID_b)];
    A_g_Equ_b_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_g,admsNodeID_s)];
    A_g_Equ_s_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_g,admsNodeID_d)];
    A_g_Equ_d_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_s,admsNodeID_s)];
    A_s_Equ_s_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_s,admsNodeID_b)];
    A_s_Equ_b_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_s,admsNodeID_d)];
    A_s_Equ_d_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_s,admsNodeID_g)];
    A_s_Equ_g_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_b,admsNodeID_g)];
    A_b_Equ_g_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_b,admsNodeID_b)];
    A_b_Equ_b_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_b,admsNodeID_s)];
    A_b_Equ_s_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];
    jacLoc = pairToJacStampMap[IntPair(admsNodeID_b,admsNodeID_d)];
    A_b_Equ_d_NodeOffset = jacLIDVec[jacLoc.first][jacLoc.second];


}

//-----------------------------------------------------------------------------
// Function      : Instance::setupPointers
// Purpose       : Create pointer variables used for referencing jacobian
//                 elements
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
void Instance::setupPointers( )
{

  Linear::Matrix & dFdx = *(extData.dFdxMatrixPtr);
  Linear::Matrix & dQdx = *(extData.dQdxMatrixPtr);
    f_d_Equ_s_Node_Ptr = &(dFdx[li_d][A_d_Equ_s_NodeOffset]);
    q_d_Equ_s_Node_Ptr = &(dQdx[li_d][A_d_Equ_s_NodeOffset]);
    f_d_Equ_b_Node_Ptr = &(dFdx[li_d][A_d_Equ_b_NodeOffset]);
    q_d_Equ_b_Node_Ptr = &(dQdx[li_d][A_d_Equ_b_NodeOffset]);
    f_d_Equ_d_Node_Ptr = &(dFdx[li_d][A_d_Equ_d_NodeOffset]);
    q_d_Equ_d_Node_Ptr = &(dQdx[li_d][A_d_Equ_d_NodeOffset]);
    f_d_Equ_g_Node_Ptr = &(dFdx[li_d][A_d_Equ_g_NodeOffset]);
    q_d_Equ_g_Node_Ptr = &(dQdx[li_d][A_d_Equ_g_NodeOffset]);
    f_g_Equ_g_Node_Ptr = &(dFdx[li_g][A_g_Equ_g_NodeOffset]);
    q_g_Equ_g_Node_Ptr = &(dQdx[li_g][A_g_Equ_g_NodeOffset]);
    f_g_Equ_b_Node_Ptr = &(dFdx[li_g][A_g_Equ_b_NodeOffset]);
    q_g_Equ_b_Node_Ptr = &(dQdx[li_g][A_g_Equ_b_NodeOffset]);
    f_g_Equ_s_Node_Ptr = &(dFdx[li_g][A_g_Equ_s_NodeOffset]);
    q_g_Equ_s_Node_Ptr = &(dQdx[li_g][A_g_Equ_s_NodeOffset]);
    f_g_Equ_d_Node_Ptr = &(dFdx[li_g][A_g_Equ_d_NodeOffset]);
    q_g_Equ_d_Node_Ptr = &(dQdx[li_g][A_g_Equ_d_NodeOffset]);
    f_s_Equ_s_Node_Ptr = &(dFdx[li_s][A_s_Equ_s_NodeOffset]);
    q_s_Equ_s_Node_Ptr = &(dQdx[li_s][A_s_Equ_s_NodeOffset]);
    f_s_Equ_b_Node_Ptr = &(dFdx[li_s][A_s_Equ_b_NodeOffset]);
    q_s_Equ_b_Node_Ptr = &(dQdx[li_s][A_s_Equ_b_NodeOffset]);
    f_s_Equ_d_Node_Ptr = &(dFdx[li_s][A_s_Equ_d_NodeOffset]);
    q_s_Equ_d_Node_Ptr = &(dQdx[li_s][A_s_Equ_d_NodeOffset]);
    f_s_Equ_g_Node_Ptr = &(dFdx[li_s][A_s_Equ_g_NodeOffset]);
    q_s_Equ_g_Node_Ptr = &(dQdx[li_s][A_s_Equ_g_NodeOffset]);
    f_b_Equ_g_Node_Ptr = &(dFdx[li_b][A_b_Equ_g_NodeOffset]);
    q_b_Equ_g_Node_Ptr = &(dQdx[li_b][A_b_Equ_g_NodeOffset]);
    f_b_Equ_b_Node_Ptr = &(dFdx[li_b][A_b_Equ_b_NodeOffset]);
    q_b_Equ_b_Node_Ptr = &(dQdx[li_b][A_b_Equ_b_NodeOffset]);
    f_b_Equ_s_Node_Ptr = &(dFdx[li_b][A_b_Equ_s_NodeOffset]);
    q_b_Equ_s_Node_Ptr = &(dQdx[li_b][A_b_Equ_s_NodeOffset]);
    f_b_Equ_d_Node_Ptr = &(dFdx[li_b][A_b_Equ_d_NodeOffset]);
    q_b_Equ_d_Node_Ptr = &(dQdx[li_b][A_b_Equ_d_NodeOffset]);


}

// RHS load functions

//-----------------------------------------------------------------------------
// Function      : Instance::loadDAEFVector
// Purpose       : load F vector (static contributions) for one instance for
//                 NEW DAE formulation
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
bool Instance::loadDAEFVector()
{

  bool bsuccess=true;
(*extData.daeFVectorPtr)[li_d] += staticContributions[admsNodeID_d];
(*extData.daeFVectorPtr)[li_g] += staticContributions[admsNodeID_g];
(*extData.daeFVectorPtr)[li_s] += staticContributions[admsNodeID_s];
(*extData.daeFVectorPtr)[li_b] += staticContributions[admsNodeID_b];


  if (loadLeadCurrent)
  {
    double * leadF = extData.nextLeadCurrFCompRawPtr;
    leadF[li_branch_id] = leadCurrentF[admsNodeID_d];
    leadF[li_branch_ig] = leadCurrentF[admsNodeID_g];
    leadF[li_branch_is] = leadCurrentF[admsNodeID_s];
    leadF[li_branch_ib] = leadCurrentF[admsNodeID_b];



    // here we have to do special things for BJTs, MOSFETs and 2-terminal
    // devices for power computation.

        double * solVec = extData.nextSolVectorRawPtr;
        double * junctionV = extData.nextJunctionVCompRawPtr;
        junctionV[li_branch_id] = solVec[li_d] - solVec[li_s];
        junctionV[li_branch_ig] = solVec[li_g] - solVec[li_s];

  }
  return bsuccess;
}

//-----------------------------------------------------------------------------
// Function      : Instance::loadDAEQVector
// Purpose       : load Q vector (dynamic contributions) for one instance for
//                 NEW DAE formulation
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
bool Instance::loadDAEQVector()
{
(*extData.daeQVectorPtr)[li_d] += dynamicContributions[admsNodeID_d];
(*extData.daeQVectorPtr)[li_g] += dynamicContributions[admsNodeID_g];
(*extData.daeQVectorPtr)[li_s] += dynamicContributions[admsNodeID_s];
(*extData.daeQVectorPtr)[li_b] += dynamicContributions[admsNodeID_b];


  if (loadLeadCurrent)
  {
    double * leadQ = extData.nextLeadCurrQCompRawPtr;
    leadQ[li_branch_id] = leadCurrentQ[admsNodeID_d];
    leadQ[li_branch_ig] = leadCurrentQ[admsNodeID_g];
    leadQ[li_branch_is] = leadCurrentQ[admsNodeID_s];
    leadQ[li_branch_ib] = leadCurrentQ[admsNodeID_b];


  }
  return true;
}


//-----------------------------------------------------------------------------
// Function      : Instance::updatePrimaryState
// Purpose       :
// Special Notes : In this initial implementation, does little more than
//                 call updateIntermediateVars()
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
bool Instance::updatePrimaryState()
{
  bool bsuccess = true;

  bsuccess = updateIntermediateVars();

  // if old DAE were implemented, we'd save dynamic contributions as state
  // here.


  return bsuccess;
}

//-----------------------------------------------------------------------------
// Function      : Instance::updateSecondaryState
// Purpose       :
// Special Notes : In this initial implementation, does nothing
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
bool Instance::updateSecondaryState()
{
  bool bsuccess = true;

  // were old DAE implemented, we'd pull dynamic contribution derivatives
  // out of state.

  return bsuccess;
}

//-----------------------------------------------------------------------------
// Function      : Instance::updateIntermediateVars
// Purpose       : update intermediate variables for one ekv_va instance
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
bool Instance::updateIntermediateVars()
{

  bool bsuccess=true;
  Linear::Vector * solVectorPtr = extData.nextSolVectorPtr;

  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
  {
    Xyce::dout() << std::endl << subsection_divider << std::endl;
    Xyce::dout() << "  In ADMSekv_va::Instance::updateIntermediateVars\n\n";
    Xyce::dout() << "  name = " << getName() << std::endl;
  }

  // Local variables
  double qjs=0.0;
     double d_qjs_dV_s_b=0.0;
  double csswg_s=0.0;
     double d_csswg_s_dV_s_b=0.0;
  double cssw_s=0.0;
     double d_cssw_s_dV_s_b=0.0;
  double csb_s=0.0;
     double d_csb_s_dV_s_b=0.0;
  double qjd=0.0;
     double d_qjd_dV_d_b=0.0;
  double csswg_d=0.0;
     double d_csswg_d_dV_d_b=0.0;
  double cssw_d=0.0;
     double d_cssw_d_dV_d_b=0.0;
  double csb_d=0.0;
     double d_csb_d_dV_d_b=0.0;
  double isb_tun=0.0;
     double d_isb_tun_dV_s_b=0.0;
  double f_breakdown_s=0.0;
     double d_f_breakdown_s_dV_s_b=0.0;
     double d_f_breakdown_s_dV_d_b=0.0;
  double arg_s=0.0;
     double d_arg_s_dV_s_b=0.0;
  double is_s=0.0;
  double idb_tun=0.0;
     double d_idb_tun_dV_d_b=0.0;
  double f_breakdown_d=0.0;
     double d_f_breakdown_d_dV_d_b=0.0;
  double tmp0=0.0;
     double d_tmp0_dV_s_b=0.0;
     double d_tmp0_dV_d_b=0.0;
  double arg_d=0.0;
     double d_arg_d_dV_d_b=0.0;
  double is_d=0.0;
  double v_si_b=0.0;
     double d_v_si_b_dV_s_b=0.0;
  double v_di_b=0.0;
     double d_v_di_b_dV_d_b=0.0;
  double njtsswg_t=0.0;
  double njtssw_t=0.0;
  double njts_t=0.0;
  double cjswg_t=0.0;
  double cjsw_t=0.0;
  double cj_t=0.0;
  double pbswg_t=0.0;
  double pbsw_t=0.0;
  double pb_t=0.0;
  double jswg_t=0.0;
  double jsw_t=0.0;
  double js_t=0.0;
  double temp_arg=0.0;
  double pd_i=0.0;
  double ad_i=0.0;
  double ps_i=0.0;
  double as_i=0.0;
  double ddt_QS=0.0;
     double d_ddt_QS_dV_d_b=0.0;
     double d_ddt_QS_dV_s_b=0.0;
     double d_ddt_QS_dV_g_b=0.0;
  double ddt_QD=0.0;
     double d_ddt_QD_dV_d_b=0.0;
     double d_ddt_QD_dV_s_b=0.0;
     double d_ddt_QD_dV_g_b=0.0;
  double QG=0.0;
     double d_QG_dV_d_b=0.0;
     double d_QG_dV_s_b=0.0;
     double d_QG_dV_g_b=0.0;
  double QB=0.0;
     double d_QB_dV_d_b=0.0;
     double d_QB_dV_s_b=0.0;
     double d_QB_dV_g_b=0.0;
  double QI=0.0;
     double d_QI_dV_d_b=0.0;
     double d_QI_dV_s_b=0.0;
     double d_QI_dV_g_b=0.0;
  double QS=0.0;
     double d_QS_dV_d_b=0.0;
     double d_QS_dV_s_b=0.0;
     double d_QS_dV_g_b=0.0;
  double QD=0.0;
     double d_QD_dV_d_b=0.0;
     double d_QD_dV_s_b=0.0;
     double d_QD_dV_g_b=0.0;
  double n_Vt_COX=0.0;
     double d_n_Vt_COX_dV_d_b=0.0;
     double d_n_Vt_COX_dV_s_b=0.0;
     double d_n_Vt_COX_dV_g_b=0.0;
  double sqrt_PHI_VP2_2=0.0;
     double d_sqrt_PHI_VP2_2_dV_g_b=0.0;
     double d_sqrt_PHI_VP2_2_dV_d_b=0.0;
     double d_sqrt_PHI_VP2_2_dV_s_b=0.0;
  double sir3=0.0;
     double d_sir3_dV_g_b=0.0;
     double d_sir3_dV_d_b=0.0;
     double d_sir3_dV_s_b=0.0;
  double sif3=0.0;
     double d_sif3_dV_g_b=0.0;
     double d_sif3_dV_d_b=0.0;
     double d_sif3_dV_s_b=0.0;
  double WLCox=0.0;
  double dIsub_factor=0.0;
  double Isub=0.0;
     double d_Isub_dV_s_b=0.0;
     double d_Isub_dV_d_b=0.0;
     double d_Isub_dV_g_b=0.0;
  double isub=0.0;
     double d_isub_dV_s_b=0.0;
     double d_isub_dV_d_b=0.0;
     double d_isub_dV_g_b=0.0;
  double exp_ib=0.0;
     double d_exp_ib_dV_s_b=0.0;
     double d_exp_ib_dV_d_b=0.0;
     double d_exp_ib_dV_g_b=0.0;
  double Lc_IBB_Vib=0.0;
     double d_Lc_IBB_Vib_dV_s_b=0.0;
     double d_Lc_IBB_Vib_dV_d_b=0.0;
     double d_Lc_IBB_Vib_dV_g_b=0.0;
  double inv_Vib=0.0;
     double d_inv_Vib_dV_s_b=0.0;
     double d_inv_Vib_dV_d_b=0.0;
     double d_inv_Vib_dV_g_b=0.0;
  double Vib=0.0;
     double d_Vib_dV_s_b=0.0;
     double d_Vib_dV_d_b=0.0;
     double d_Vib_dV_g_b=0.0;
  double RDeff=0.0;
  double RSeff=0.0;
  double gmbs=0.0;
  double gm=0.0;
  double gms=0.0;
     double d_gms_dV_g_b=0.0;
     double d_gms_dV_d_b=0.0;
     double d_gms_dV_s_b=0.0;
  double gds=0.0;
     double d_gds_dV_g_b=0.0;
     double d_gds_dV_d_b=0.0;
     double d_gds_dV_s_b=0.0;
  double dn_dVG=0.0;
  double dn_dVS=0.0;
     double d_dn_dVS_dV_g_b=0.0;
     double d_dn_dVS_dV_d_b=0.0;
     double d_dn_dVS_dV_s_b=0.0;
  double dn_dVD=0.0;
     double d_dn_dVD_dV_g_b=0.0;
     double d_dn_dVD_dV_d_b=0.0;
     double d_dn_dVD_dV_s_b=0.0;
  double dbeta_dVG=0.0;
  double dbeta_dVS=0.0;
     double d_dbeta_dVS_dV_g_b=0.0;
     double d_dbeta_dVS_dV_d_b=0.0;
     double d_dbeta_dVS_dV_s_b=0.0;
  double dbeta_dVD=0.0;
     double d_dbeta_dVD_dV_g_b=0.0;
     double d_dbeta_dVD_dV_d_b=0.0;
     double d_dbeta_dVD_dV_s_b=0.0;
  double dVPprime_dVG=0.0;
  double dVPprime_dVS=0.0;
     double d_dVPprime_dVS_dV_g_b=0.0;
     double d_dVPprime_dVS_dV_d_b=0.0;
     double d_dVPprime_dVS_dV_s_b=0.0;
  double dVPprime_dVD=0.0;
     double d_dVPprime_dVD_dV_g_b=0.0;
     double d_dVPprime_dVD_dV_d_b=0.0;
     double d_dVPprime_dVD_dV_s_b=0.0;
  double dQB_dVG=0.0;
  double dQB_dVS=0.0;
     double d_dQB_dVS_dV_g_b=0.0;
     double d_dQB_dVS_dV_d_b=0.0;
     double d_dQB_dVS_dV_s_b=0.0;
  double dQB_dVD=0.0;
     double d_dQB_dVD_dV_g_b=0.0;
     double d_dQB_dVD_dV_d_b=0.0;
     double d_dQB_dVD_dV_s_b=0.0;
  double dQI_dVG=0.0;
  double dQI_dVS=0.0;
     double d_dQI_dVS_dV_g_b=0.0;
     double d_dQI_dVS_dV_d_b=0.0;
     double d_dQI_dVS_dV_s_b=0.0;
  double dQI_dVD=0.0;
     double d_dQI_dVD_dV_g_b=0.0;
     double d_dQI_dVD_dV_d_b=0.0;
     double d_dQI_dVD_dV_s_b=0.0;
  double dir_dVG=0.0;
  double dir_dVS=0.0;
     double d_dir_dVS_dV_g_b=0.0;
     double d_dir_dVS_dV_d_b=0.0;
     double d_dir_dVS_dV_s_b=0.0;
  double dir_dVD=0.0;
     double d_dir_dVD_dV_g_b=0.0;
     double d_dir_dVD_dV_d_b=0.0;
     double d_dir_dVD_dV_s_b=0.0;
  double dLeq_dVG=0.0;
  double dLeq_dVS=0.0;
     double d_dLeq_dVS_dV_g_b=0.0;
     double d_dLeq_dVS_dV_d_b=0.0;
     double d_dLeq_dVS_dV_s_b=0.0;
  double dLeq_dVD=0.0;
     double d_dLeq_dVD_dV_g_b=0.0;
     double d_dLeq_dVD_dV_d_b=0.0;
     double d_dLeq_dVD_dV_s_b=0.0;
  double ddeltaL_dVG=0.0;
  double ddeltaL_dVS=0.0;
     double d_ddeltaL_dVS_dV_g_b=0.0;
     double d_ddeltaL_dVS_dV_d_b=0.0;
     double d_ddeltaL_dVS_dV_s_b=0.0;
  double ddeltaL_dVD=0.0;
     double d_ddeltaL_dVD_dV_g_b=0.0;
     double d_ddeltaL_dVD_dV_d_b=0.0;
     double d_ddeltaL_dVD_dV_s_b=0.0;
  double dirprime_dVG=0.0;
  double dirprime_dVS=0.0;
     double d_dirprime_dVS_dV_g_b=0.0;
     double d_dirprime_dVS_dV_d_b=0.0;
     double d_dirprime_dVS_dV_s_b=0.0;
  double dirprime_dVD=0.0;
     double d_dirprime_dVD_dV_g_b=0.0;
     double d_dirprime_dVD_dV_d_b=0.0;
     double d_dirprime_dVD_dV_s_b=0.0;
  double dVDSSprime_dVG=0.0;
  double dVDSSprime_dVS=0.0;
     double d_dVDSSprime_dVS_dV_g_b=0.0;
     double d_dVDSSprime_dVS_dV_d_b=0.0;
     double d_dVDSSprime_dVS_dV_s_b=0.0;
  double dVDSSprime_dVD=0.0;
     double d_dVDSSprime_dVD_dV_g_b=0.0;
     double d_dVDSSprime_dVD_dV_d_b=0.0;
     double d_dVDSSprime_dVD_dV_s_b=0.0;
  double dVip_dVG=0.0;
  double dVip_dVS=0.0;
     double d_dVip_dVS_dV_g_b=0.0;
     double d_dVip_dVS_dV_d_b=0.0;
     double d_dVip_dVS_dV_s_b=0.0;
  double dVip_dVD=0.0;
     double d_dVip_dVD_dV_g_b=0.0;
     double d_dVip_dVD_dV_d_b=0.0;
     double d_dVip_dVD_dV_s_b=0.0;
  double ddeltaV_dVG=0.0;
  double ddeltaV_dVS=0.0;
     double d_ddeltaV_dVS_dV_g_b=0.0;
     double d_ddeltaV_dVS_dV_d_b=0.0;
     double d_ddeltaV_dVS_dV_s_b=0.0;
  double ddeltaV_dVD=0.0;
     double d_ddeltaV_dVD_dV_g_b=0.0;
     double d_ddeltaV_dVD_dV_d_b=0.0;
     double d_ddeltaV_dVD_dV_s_b=0.0;
  double dVDSS_dVG=0.0;
  double dVDSS_dVS=0.0;
     double d_dVDSS_dVS_dV_g_b=0.0;
     double d_dVDSS_dVS_dV_d_b=0.0;
     double d_dVDSS_dVS_dV_s_b=0.0;
  double dVDSS_dVD=0.0;
     double d_dVDSS_dVD_dV_g_b=0.0;
     double d_dVDSS_dVD_dV_d_b=0.0;
     double d_dVDSS_dVD_dV_s_b=0.0;
  double dif_dVG=0.0;
  double dif_dVS=0.0;
     double d_dif_dVS_dV_g_b=0.0;
     double d_dif_dVS_dV_d_b=0.0;
     double d_dif_dVS_dV_s_b=0.0;
  double dif_dVD=0.0;
     double d_dif_dVD_dV_g_b=0.0;
     double d_dif_dVD_dV_d_b=0.0;
     double d_dif_dVD_dV_s_b=0.0;
  double dVP_dVG=0.0;
  double dVP_dVS=0.0;
     double d_dVP_dVS_dV_g_b=0.0;
     double d_dVP_dVS_dV_d_b=0.0;
     double d_dVP_dVS_dV_s_b=0.0;
  double dVP_dVD=0.0;
     double d_dVP_dVD_dV_g_b=0.0;
     double d_dVP_dVD_dV_d_b=0.0;
     double d_dVP_dVD_dV_s_b=0.0;
  double tmp3=0.0;
     double d_tmp3_dV_g_b=0.0;
     double d_tmp3_dV_d_b=0.0;
     double d_tmp3_dV_s_b=0.0;
  double dGAMMAprime_dVG=0.0;
  double dGAMMAprime_dVS=0.0;
     double d_dGAMMAprime_dVS_dV_g_b=0.0;
     double d_dGAMMAprime_dVS_dV_d_b=0.0;
     double d_dGAMMAprime_dVS_dV_s_b=0.0;
  double dGAMMAprime_dVD=0.0;
     double d_dGAMMAprime_dVD_dV_g_b=0.0;
     double d_dGAMMAprime_dVD_dV_d_b=0.0;
     double d_dGAMMAprime_dVD_dV_s_b=0.0;
  double Gn=0.0;
  double Vdsat=0.0;
  double Von=0.0;
  double Id=0.0;
     double d_Id_dV_g_b=0.0;
     double d_Id_dV_d_b=0.0;
     double d_Id_dV_s_b=0.0;
  double Ispec=0.0;
     double d_Ispec_dV_g_b=0.0;
     double d_Ispec_dV_d_b=0.0;
     double d_Ispec_dV_s_b=0.0;
  double if_ir=0.0;
     double d_if_ir_dV_g_b=0.0;
     double d_if_ir_dV_d_b=0.0;
     double d_if_ir_dV_s_b=0.0;
  double n=0.0;
     double d_n_dV_g_b=0.0;
     double d_n_dV_d_b=0.0;
     double d_n_dV_s_b=0.0;
  double sqrt_PHI_VP=0.0;
     double d_sqrt_PHI_VP_dV_g_b=0.0;
     double d_sqrt_PHI_VP_dV_d_b=0.0;
     double d_sqrt_PHI_VP_dV_s_b=0.0;
  double beta=0.0;
     double d_beta_dV_s_b=0.0;
     double d_beta_dV_d_b=0.0;
     double d_beta_dV_g_b=0.0;
  double T0_GAMMA_1=0.0;
  double E0_Q_1=0.0;
     double d_E0_Q_1_dV_g_b=0.0;
     double d_E0_Q_1_dV_d_b=0.0;
     double d_E0_Q_1_dV_s_b=0.0;
  double qb=0.0;
     double d_qb_dV_g_b=0.0;
     double d_qb_dV_d_b=0.0;
     double d_qb_dV_s_b=0.0;
  double qi=0.0;
     double d_qi_dV_g_b=0.0;
     double d_qi_dV_d_b=0.0;
     double d_qi_dV_s_b=0.0;
  double n_1_n=0.0;
     double d_n_1_n_dV_g_b=0.0;
     double d_n_1_n_dV_d_b=0.0;
     double d_n_1_n_dV_s_b=0.0;
  double n_1=0.0;
     double d_n_1_dV_g_b=0.0;
     double d_n_1_dV_d_b=0.0;
     double d_n_1_dV_s_b=0.0;
  double sqrt_PHI_VP_2=0.0;
     double d_sqrt_PHI_VP_2_dV_g_b=0.0;
     double d_sqrt_PHI_VP_2_dV_d_b=0.0;
     double d_sqrt_PHI_VP_2_dV_s_b=0.0;
  double VP_PHI_eps=0.0;
     double d_VP_PHI_eps_dV_g_b=0.0;
     double d_VP_PHI_eps_dV_d_b=0.0;
     double d_VP_PHI_eps_dV_s_b=0.0;
  double sif_sir_2=0.0;
     double d_sif_sir_2_dV_g_b=0.0;
     double d_sif_sir_2_dV_d_b=0.0;
     double d_sif_sir_2_dV_s_b=0.0;
  double sir=0.0;
     double d_sir_dV_g_b=0.0;
     double d_sir_dV_d_b=0.0;
     double d_sir_dV_s_b=0.0;
  double sif=0.0;
     double d_sif_dV_g_b=0.0;
     double d_sif_dV_d_b=0.0;
     double d_sif_dV_s_b=0.0;
  double sir2=0.0;
     double d_sir2_dV_g_b=0.0;
     double d_sir2_dV_d_b=0.0;
     double d_sir2_dV_s_b=0.0;
  double sif2=0.0;
     double d_sif2_dV_g_b=0.0;
     double d_sif2_dV_d_b=0.0;
     double d_sif2_dV_s_b=0.0;
  double dir_dv=0.0;
     double d_dir_dv_dV_g_b=0.0;
     double d_dir_dv_dV_d_b=0.0;
     double d_dir_dv_dV_s_b=0.0;
  double sqrt_ir=0.0;
  double ir=0.0;
     double d_ir_dV_g_b=0.0;
     double d_ir_dV_d_b=0.0;
     double d_ir_dV_s_b=0.0;
  double Leq=0.0;
     double d_Leq_dV_s_b=0.0;
     double d_Leq_dV_d_b=0.0;
     double d_Leq_dV_g_b=0.0;
  double sqrt_Lprime_Lmin=0.0;
     double d_sqrt_Lprime_Lmin_dV_s_b=0.0;
     double d_sqrt_Lprime_Lmin_dV_d_b=0.0;
     double d_sqrt_Lprime_Lmin_dV_g_b=0.0;
  double Lmin=0.0;
  double Lprime=0.0;
     double d_Lprime_dV_s_b=0.0;
     double d_Lprime_dV_d_b=0.0;
     double d_Lprime_dV_g_b=0.0;
  double deltaL=0.0;
     double d_deltaL_dV_s_b=0.0;
     double d_deltaL_dV_d_b=0.0;
     double d_deltaL_dV_g_b=0.0;
  double dirprime_dv=0.0;
     double d_dirprime_dv_dV_g_b=0.0;
     double d_dirprime_dv_dV_d_b=0.0;
     double d_dirprime_dv_dV_s_b=0.0;
  double sqrt_irprime=0.0;
  double irprime=0.0;
     double d_irprime_dV_g_b=0.0;
     double d_irprime_dV_d_b=0.0;
     double d_irprime_dV_s_b=0.0;
  double sqrt_Vds_VDSSprime_deltaV=0.0;
     double d_sqrt_Vds_VDSSprime_deltaV_dV_s_b=0.0;
     double d_sqrt_Vds_VDSSprime_deltaV_dV_d_b=0.0;
     double d_sqrt_Vds_VDSSprime_deltaV_dV_g_b=0.0;
  double sqrt_VDSSprime_deltaV=0.0;
     double d_sqrt_VDSSprime_deltaV_dV_g_b=0.0;
     double d_sqrt_VDSSprime_deltaV_dV_d_b=0.0;
     double d_sqrt_VDSSprime_deltaV_dV_s_b=0.0;
  double Vdsprime=0.0;
     double d_Vdsprime_dV_s_b=0.0;
     double d_Vdsprime_dV_d_b=0.0;
     double d_Vdsprime_dV_g_b=0.0;
  double VDSSprime=0.0;
     double d_VDSSprime_dV_g_b=0.0;
     double d_VDSSprime_dV_d_b=0.0;
     double d_VDSSprime_dV_s_b=0.0;
  double VDSSprime_sqrt=0.0;
     double d_VDSSprime_sqrt_dV_g_b=0.0;
     double d_VDSSprime_sqrt_dV_d_b=0.0;
     double d_VDSSprime_sqrt_dV_s_b=0.0;
  double Vip=0.0;
     double d_Vip_dV_g_b=0.0;
     double d_Vip_dV_d_b=0.0;
     double d_Vip_dV_s_b=0.0;
  double sqrt_Vds_VDSS_deltaV=0.0;
     double d_sqrt_Vds_VDSS_deltaV_dV_s_b=0.0;
     double d_sqrt_Vds_VDSS_deltaV_dV_d_b=0.0;
     double d_sqrt_Vds_VDSS_deltaV_dV_g_b=0.0;
  double sqrt_VDSS_deltaV=0.0;
     double d_sqrt_VDSS_deltaV_dV_g_b=0.0;
     double d_sqrt_VDSS_deltaV_dV_d_b=0.0;
     double d_sqrt_VDSS_deltaV_dV_s_b=0.0;
  double deltaV_2=0.0;
     double d_deltaV_2_dV_g_b=0.0;
     double d_deltaV_2_dV_d_b=0.0;
     double d_deltaV_2_dV_s_b=0.0;
  double Vds=0.0;
     double d_Vds_dV_s_b=0.0;
     double d_Vds_dV_d_b=0.0;
  double VDSS=0.0;
     double d_VDSS_dV_g_b=0.0;
     double d_VDSS_dV_d_b=0.0;
     double d_VDSS_dV_s_b=0.0;
  double VDSS_sqrt=0.0;
     double d_VDSS_sqrt_dV_g_b=0.0;
     double d_VDSS_sqrt_dV_d_b=0.0;
     double d_VDSS_sqrt_dV_s_b=0.0;
  double Vt_Vc=0.0;
  double dif_dv=0.0;
     double d_dif_dv_dV_g_b=0.0;
     double d_dif_dv_dV_d_b=0.0;
     double d_dif_dv_dV_s_b=0.0;
  double sqrt_if=0.0;
     double d_sqrt_if_dV_g_b=0.0;
     double d_sqrt_if_dV_d_b=0.0;
     double d_sqrt_if_dV_s_b=0.0;
  double if_=0.0;
     double d_if__dV_g_b=0.0;
     double d_if__dV_d_b=0.0;
     double d_if__dV_s_b=0.0;
  double yk=0.0;
     double d_yk_dV_g_b=0.0;
     double d_yk_dV_d_b=0.0;
     double d_yk_dV_s_b=0.0;
  double zk=0.0;
     double d_zk_dV_g_b=0.0;
     double d_zk_dV_d_b=0.0;
     double d_zk_dV_s_b=0.0;
  double z0=0.0;
     double d_z0_dV_g_b=0.0;
     double d_z0_dV_d_b=0.0;
     double d_z0_dV_s_b=0.0;
  double VP=0.0;
     double d_VP_dV_g_b=0.0;
     double d_VP_dV_d_b=0.0;
     double d_VP_dV_s_b=0.0;
  double big_sqrt_VP=0.0;
     double d_big_sqrt_VP_dV_g_b=0.0;
     double d_big_sqrt_VP_dV_d_b=0.0;
     double d_big_sqrt_VP_dV_s_b=0.0;
  double GAMMAprime=0.0;
     double d_GAMMAprime_dV_d_b=0.0;
     double d_GAMMAprime_dV_s_b=0.0;
     double d_GAMMAprime_dV_g_b=0.0;
  double sqrt_GAMMAstar=0.0;
     double d_sqrt_GAMMAstar_dV_d_b=0.0;
     double d_sqrt_GAMMAstar_dV_s_b=0.0;
     double d_sqrt_GAMMAstar_dV_g_b=0.0;
  double GAMMAstar=0.0;
     double d_GAMMAstar_dV_d_b=0.0;
     double d_GAMMAstar_dV_s_b=0.0;
     double d_GAMMAstar_dV_g_b=0.0;
  double sqrt_PHI_VP0=0.0;
     double d_sqrt_PHI_VP0_dV_g_b=0.0;
  double VP0=0.0;
     double d_VP0_dV_g_b=0.0;
  double big_sqrt_VP0=0.0;
     double d_big_sqrt_VP0_dV_g_b=0.0;
  double LETA_L=0.0;
  double WETA_W=0.0;
  double sqrt_PHI_VD=0.0;
     double d_sqrt_PHI_VD_dV_s_b=0.0;
     double d_sqrt_PHI_VD_dV_d_b=0.0;
  double sqrt_PHI_VD_Vt=0.0;
     double d_sqrt_PHI_VD_Vt_dV_s_b=0.0;
     double d_sqrt_PHI_VD_Vt_dV_d_b=0.0;
  double PHI_VD=0.0;
     double d_PHI_VD_dV_s_b=0.0;
     double d_PHI_VD_dV_d_b=0.0;
  double sqrt_PHI_VS=0.0;
     double d_sqrt_PHI_VS_dV_d_b=0.0;
     double d_sqrt_PHI_VS_dV_s_b=0.0;
  double sqrt_PHI_VS_Vt=0.0;
     double d_sqrt_PHI_VS_Vt_dV_d_b=0.0;
     double d_sqrt_PHI_VS_Vt_dV_s_b=0.0;
  double PHI_VS=0.0;
     double d_PHI_VS_dV_d_b=0.0;
     double d_PHI_VS_dV_s_b=0.0;
  double VGprime=0.0;
     double d_VGprime_dV_g_b=0.0;
  double sqrt_VGstar=0.0;
     double d_sqrt_VGstar_dV_g_b=0.0;
  double VGstar=0.0;
     double d_VGstar_dV_g_b=0.0;
  double T1=0.0;
     double d_T1_dV_s_b=0.0;
  int Mode=0.0;
  double VD=0.0;
     double d_VD_dV_s_b=0.0;
     double d_VD_dV_d_b=0.0;
  double VS=0.0;
     double d_VS_dV_d_b=0.0;
     double d_VS_dV_s_b=0.0;
  double VG=0.0;
     double d_VG_dV_g_b=0.0;
  double deltaVFB=0.0;
  double vL=0.0;
  double GAMMA_sqrt_PHI=0.0;
  double GAMMA_S=0.0;
  double KP_Weff=0.0;
  double VTO_S=0.0;
  double AWL=0.0;
  double log_Vc_Vt=0.0;
  double Vc=0.0;
  double Weff=0.0;
  double Leff=0.0;
  double IBA_IBB=0.0;
  double Lc_IBB=0.0;
  double Lc_UCRIT=0.0;
  double inv_UCRIT=0.0;
  double sqrt_PHI=0.0;
  double tmp2=0.0;
     double d_tmp2_dV_d_b=0.0;
     double d_tmp2_dV_s_b=0.0;
     double d_tmp2_dV_g_b=0.0;
  double tmp1=0.0;
     double d_tmp1_dV_g_b=0.0;
     double d_tmp1_dV_d_b=0.0;
     double d_tmp1_dV_s_b=0.0;
  double PHI_T=0.0;
  double IBB_T=0.0;
  double UCRIT_T=0.0;
  double KP_T=0.0;
  double VTO_T=0.0;
  double ratioT=0.0;
  double deltaT=0.0;
  double refEg=0.0;
  double Eg=0.0;
  double Vt_Vt_16=0.0;
  double Vt_Vt_2=0.0;
  double Vt_Vt=0.0;
  double Vt_4=0.0;
  double Vt_2=0.0;
  double inv_Vt=0.0;
  double Vt_01=0.0;
  double Vt=0.0;
  double Tnom=0.0;
  double T=0.0;
  double eta_qi=0.0;
  double V0=0.0;
  double T0=0.0;
  double IBN_2=0.0;
  double eps_COX_L=0.0;
  double eps_COX_W=0.0;
  double Lc_LAMBDA=0.0;
  double Lc=0.0;
  double eps_COX=0.0;
  double sqrt_VP_Vt=0.0;
     double d_sqrt_VP_Vt_dV_g_b=0.0;
     double d_sqrt_VP_Vt_dV_d_b=0.0;
     double d_sqrt_VP_Vt_dV_s_b=0.0;
  double VPprime=0.0;
     double d_VPprime_dV_g_b=0.0;
     double d_VPprime_dV_d_b=0.0;
     double d_VPprime_dV_s_b=0.0;
  double THETA_VP_1=0.0;
     double d_THETA_VP_1_dV_g_b=0.0;
     double d_THETA_VP_1_dV_d_b=0.0;
     double d_THETA_VP_1_dV_s_b=0.0;
  double Ibd=0.0;
  double epssil=0.0;
  double EPSOX=0.0;


  // set the sizes of the Fad arrays:

  if (probeVars.size() != (3))
  {
    probeVars.resize(3);
    d_probeVars.resize(3);
    for (int i=0;i<3;i++)
    {
      d_probeVars[i].resize(3);
      for (int j=0;j<3;j++)
        d_probeVars[i][j]=0.0;
    }
    staticContributions.resize(4+0);
    d_staticContributions.resize(4+0);
    for (int i=0;i<4+0;i++)
      d_staticContributions[i].resize(3);
    dynamicContributions.resize(4+0);
    d_dynamicContributions.resize(4+0);
    for (int i=0;i<4+0;i++)
      d_dynamicContributions[i].resize(3);
  }

    noiseContribsPower.resize(2);
    noiseContribsExponent.resize(2);

  // initialize contributions to zero (automatically sets derivatives to zero)
  for (int i=0; i < 4+0 ; ++i)
  {
     staticContributions[i]=0;
     for (int j=0;j<3;j++)
        d_staticContributions[i][j] = 0.0;
     dynamicContributions[i]=0;
     for (int j=0;j<3;j++)
        d_dynamicContributions[i][j] = 0.0;
  }

  // extract solution variables and set as Fad independent variables.
probeVars[admsProbeID_V_d_b] = (*solVectorPtr)[li_d] - (*solVectorPtr)[li_b];
d_probeVars[admsProbeID_V_d_b][admsProbeID_V_d_b] = 1.0;
probeVars[admsProbeID_V_s_b] = (*solVectorPtr)[li_s] - (*solVectorPtr)[li_b];
d_probeVars[admsProbeID_V_s_b][admsProbeID_V_s_b] = 1.0;
probeVars[admsProbeID_V_g_b] = (*solVectorPtr)[li_g] - (*solVectorPtr)[li_b];
d_probeVars[admsProbeID_V_g_b][admsProbeID_V_g_b] = 1.0;
// -- code converted from analog/code block
EPSOX = (3.9*8.85418792394420013968e-12);
epssil = (11.7*8.85418792394420013968e-12);
Ibd = 0.0;

d_THETA_VP_1_dV_g_b = d_THETA_VP_1_dV_d_b = d_THETA_VP_1_dV_s_b =  0.0;
THETA_VP_1 = 0.0;

d_VPprime_dV_g_b = d_VPprime_dV_d_b = d_VPprime_dV_s_b =  0.0;
VPprime = 0.0;

d_sqrt_VP_Vt_dV_g_b = d_sqrt_VP_Vt_dV_d_b = d_sqrt_VP_Vt_dV_s_b =  0.0;
sqrt_VP_Vt = 0.0;
eps_COX = (epssil/(model_.COX));
{
double value_sqrt_0 = sqrt((eps_COX*(model_.XJ)));
Lc = value_sqrt_0;
}
Lc_LAMBDA = (Lc*(model_.LAMBDA));
eps_COX_W = ((3.0*eps_COX)*(model_.WETA));
eps_COX_L = (eps_COX*(model_.LETA));
IBN_2 = ((model_.IBN)+(model_.IBN));
T0 = ((model_.COX)/(epssil*(model_.E0)));
V0 = (((model_.Q0)+(model_.Q0))/(model_.COX));
eta_qi = (((model_.TYPE)>0)?0.5:0.3333333333333);
if (((model_.TEMP)==1.0e21))
{
T = (admsTemperature+(model_.Trise));
}
else
{
T = ((model_.TEMP)+273.15);
}
if (((model_.TNOM)==1.0e21))
{
Tnom = (25+273.15);
}
else
{
Tnom = ((model_.TNOM)+273.15);
}
Vt = adms_vt(T);
Vt_01 = (0.1*Vt);
inv_Vt = (1.0/Vt);
Vt_2 = (Vt+Vt);
Vt_4 = (Vt_2+Vt_2);
Vt_Vt = (Vt*Vt);
Vt_Vt_2 = (Vt_Vt+Vt_Vt);
Vt_Vt_16 = (16.0*Vt_Vt);
Eg = (1.16-(((7.02e-4*T)*T)/(T+1108.0)));
refEg = (1.16-(((7.02e-4*Tnom)*Tnom)/(Tnom+1108.0)));
deltaT = (T-Tnom);
ratioT = (T/Tnom);
VTO_T = ((model_.VTO)-((model_.TCV)*deltaT));
{
double value_pow_0 = pow(ratioT,(model_.BEX));
KP_T = ((model_.KP)*value_pow_0);
}
{
double value_pow_0 = pow(ratioT,(model_.UCEX));
UCRIT_T = ((model_.UCRIT)*value_pow_0);
}
IBB_T = ((model_.IBB)*(1.0+((model_.IBBT)*deltaT)));
{
double value_log_0 = log(ratioT);
PHI_T = (((((model_.PHI)*ratioT)-((3.0*Vt)*value_log_0))-(refEg*ratioT))+Eg);
}

d_tmp1_dV_g_b = d_tmp1_dV_d_b = d_tmp1_dV_s_b =  0.0;
tmp1 = 0.2;

d_tmp2_dV_d_b = d_tmp2_dV_s_b = d_tmp2_dV_g_b =  0.0;
tmp2 = (PHI_T-tmp1);
{
double value_sqrt_0 = sqrt(((tmp2*tmp2)+(Vt*Vt)));
PHI_T = ((0.5*(tmp2+value_sqrt_0))+tmp1);
}
{
double value_sqrt_0 = sqrt(PHI_T);
sqrt_PHI = value_sqrt_0;
}
inv_UCRIT = (1.0/UCRIT_T);
Lc_UCRIT = (Lc*UCRIT_T);
Lc_IBB = (Lc*IBB_T);
IBA_IBB = ((model_.IBA)/IBB_T);
Leff = (L+(model_.DL));
Weff = (W+(model_.DW));
Vc = (UCRIT_T*Leff);
{
double value_log_0 = log(((0.5*Vc)*inv_Vt));
log_Vc_Vt = (Vt*(value_log_0-0.6));
}
{
double value_sqrt_0 = sqrt((Weff*Leff));
AWL = (1.0/value_sqrt_0);
}
if (((model_.TYPE)>0))
{
VTO_S = (((model_.AVTO)!=1e-6)?((AWL*((model_.AVTO)-1e-6))+VTO_T):VTO_T);
}
else
{
VTO_S = (((model_.AVTO)!=1e-6)?((AWL*(1e-6-(model_.AVTO)))-VTO_T):(-VTO_T));
}
KP_Weff = (Weff*(((model_.AKP)!=1e-6)?(KP_T*(1+(((model_.AKP)-1e-6)*AWL))):KP_T));
GAMMA_S = (((model_.AGAMMA)!=1e-6)?((model_.GAMMA)+(((model_.AGAMMA)-1e-6)*AWL)):(model_.GAMMA));
GAMMA_sqrt_PHI = (GAMMA_S*sqrt_PHI);
if ((V0==0.0))
{
deltaVFB = 0.0;
}
else
//Begin block VGprime_block
{
//Block-local variables for block VGprime_block
double sqv=0.0;
//End of Block-local variables
vL = (0.28*((Leff/((model_.LK)*NS))-0.1));
{
double value_sqrt_0 = sqrt(((vL*vL)+1.936e-3));
sqv = (1.0/(1.0+(0.5*(vL+value_sqrt_0))));
}
deltaVFB = ((V0*sqv)*sqv);
}
// End block VGprime_block

d_VG_dV_g_b = (model_.TYPE)*d_probeVars[admsProbeID_V_g_b][admsProbeID_V_g_b];
VG = ((model_.TYPE)*(probeVars[admsProbeID_V_g_b]));

d_VS_dV_d_b =  0.0;
d_VS_dV_s_b = (model_.TYPE)*d_probeVars[admsProbeID_V_s_b][admsProbeID_V_s_b];
VS = ((model_.TYPE)*(probeVars[admsProbeID_V_s_b]));

d_VD_dV_s_b =  0.0;
d_VD_dV_d_b = (model_.TYPE)*d_probeVars[admsProbeID_V_d_b][admsProbeID_V_d_b];
VD = ((model_.TYPE)*(probeVars[admsProbeID_V_d_b]));
if (((VD-VS)<0))
{
Mode = (-1);

d_T1_dV_s_b = d_VS_dV_s_b;
T1 = VS;

d_VS_dV_s_b =  0.0;
d_VS_dV_d_b = d_VD_dV_d_b;
VS = VD;

d_VD_dV_d_b =  0.0;
d_VD_dV_s_b = d_T1_dV_s_b;
VD = T1;
}
else
{
Mode = 1;
}

d_VGstar_dV_g_b = d_VG_dV_g_b;
VGstar = ((((VG-VTO_S)-deltaVFB)+PHI_T)+GAMMA_sqrt_PHI);
{
double value_sqrt_0 = sqrt(((VGstar*VGstar)+(2.0*Vt_Vt_16)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_VGstar_dV_g_b = (deriv_sqrt_0_d0*((VGstar*d_VGstar_dV_g_b+d_VGstar_dV_g_b*VGstar)));
sqrt_VGstar = value_sqrt_0;
}

d_VGprime_dV_g_b = 0.5*(d_VGstar_dV_g_b+d_sqrt_VGstar_dV_g_b);
VGprime = (0.5*(VGstar+sqrt_VGstar));

d_PHI_VS_dV_s_b = d_VS_dV_s_b;
d_PHI_VS_dV_d_b = d_VS_dV_d_b;
PHI_VS = (PHI_T+VS);
{
double value_sqrt_0 = sqrt(((PHI_VS*PHI_VS)+Vt_Vt_16));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_PHI_VS_Vt_dV_s_b = (deriv_sqrt_0_d0*((PHI_VS*d_PHI_VS_dV_s_b+d_PHI_VS_dV_s_b*PHI_VS)));
d_sqrt_PHI_VS_Vt_dV_d_b = (deriv_sqrt_0_d0*((PHI_VS*d_PHI_VS_dV_d_b+d_PHI_VS_dV_d_b*PHI_VS)));
sqrt_PHI_VS_Vt = value_sqrt_0;
}
{
double value_sqrt_0 = sqrt((0.5*(PHI_VS+sqrt_PHI_VS_Vt)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_PHI_VS_dV_s_b = (deriv_sqrt_0_d0*(0.5*(d_PHI_VS_dV_s_b+d_sqrt_PHI_VS_Vt_dV_s_b)));
d_sqrt_PHI_VS_dV_d_b = (deriv_sqrt_0_d0*(0.5*(d_PHI_VS_dV_d_b+d_sqrt_PHI_VS_Vt_dV_d_b)));
sqrt_PHI_VS = value_sqrt_0;
}

d_PHI_VD_dV_d_b = d_VD_dV_d_b;
d_PHI_VD_dV_s_b = d_VD_dV_s_b;
PHI_VD = (PHI_T+VD);
{
double value_sqrt_0 = sqrt(((PHI_VD*PHI_VD)+Vt_Vt_16));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_PHI_VD_Vt_dV_d_b = (deriv_sqrt_0_d0*((PHI_VD*d_PHI_VD_dV_d_b+d_PHI_VD_dV_d_b*PHI_VD)));
d_sqrt_PHI_VD_Vt_dV_s_b = (deriv_sqrt_0_d0*((PHI_VD*d_PHI_VD_dV_s_b+d_PHI_VD_dV_s_b*PHI_VD)));
sqrt_PHI_VD_Vt = value_sqrt_0;
}
{
double value_sqrt_0 = sqrt((0.5*(PHI_VD+sqrt_PHI_VD_Vt)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_PHI_VD_dV_d_b = (deriv_sqrt_0_d0*(0.5*(d_PHI_VD_dV_d_b+d_sqrt_PHI_VD_Vt_dV_d_b)));
d_sqrt_PHI_VD_dV_s_b = (deriv_sqrt_0_d0*(0.5*(d_PHI_VD_dV_s_b+d_sqrt_PHI_VD_Vt_dV_s_b)));
sqrt_PHI_VD = value_sqrt_0;
}
WETA_W = ((eps_COX_W*M)/Weff);
LETA_L = ((eps_COX_L*NS)/Leff);
{
double value_sqrt_0 = sqrt((VGprime+((0.25*GAMMA_S)*GAMMA_S)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_big_sqrt_VP0_dV_g_b = (deriv_sqrt_0_d0*(d_VGprime_dV_g_b));
big_sqrt_VP0 = value_sqrt_0;
}

d_VP0_dV_g_b = (d_VGprime_dV_g_b-GAMMA_S*d_big_sqrt_VP0_dV_g_b);
VP0 = ((VGprime-PHI_T)-(GAMMA_S*(big_sqrt_VP0-(0.5*GAMMA_S))));
{
double value_sqrt_0 = sqrt(((VP0+PHI_T)+Vt_01));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_PHI_VP0_dV_g_b = (deriv_sqrt_0_d0*(d_VP0_dV_g_b));
sqrt_PHI_VP0 = value_sqrt_0;
}

d_GAMMAstar_dV_g_b = WETA_W*d_sqrt_PHI_VP0_dV_g_b;
d_GAMMAstar_dV_s_b = (-LETA_L*(d_sqrt_PHI_VS_dV_s_b+d_sqrt_PHI_VD_dV_s_b));
d_GAMMAstar_dV_d_b = (-LETA_L*(d_sqrt_PHI_VS_dV_d_b+d_sqrt_PHI_VD_dV_d_b));
GAMMAstar = ((GAMMA_S-(LETA_L*(sqrt_PHI_VS+sqrt_PHI_VD)))+(WETA_W*sqrt_PHI_VP0));
{
double value_sqrt_0 = sqrt(((GAMMAstar*GAMMAstar)+Vt_01));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_GAMMAstar_dV_g_b = (deriv_sqrt_0_d0*((GAMMAstar*d_GAMMAstar_dV_g_b+d_GAMMAstar_dV_g_b*GAMMAstar)));
d_sqrt_GAMMAstar_dV_s_b = (deriv_sqrt_0_d0*((GAMMAstar*d_GAMMAstar_dV_s_b+d_GAMMAstar_dV_s_b*GAMMAstar)));
d_sqrt_GAMMAstar_dV_d_b = (deriv_sqrt_0_d0*((GAMMAstar*d_GAMMAstar_dV_d_b+d_GAMMAstar_dV_d_b*GAMMAstar)));
sqrt_GAMMAstar = value_sqrt_0;
}

d_GAMMAprime_dV_g_b = 0.5*(d_GAMMAstar_dV_g_b+d_sqrt_GAMMAstar_dV_g_b);
d_GAMMAprime_dV_s_b = 0.5*(d_GAMMAstar_dV_s_b+d_sqrt_GAMMAstar_dV_s_b);
d_GAMMAprime_dV_d_b = 0.5*(d_GAMMAstar_dV_d_b+d_sqrt_GAMMAstar_dV_d_b);
GAMMAprime = (0.5*(GAMMAstar+sqrt_GAMMAstar));
{
double value_sqrt_0 = sqrt((VGprime+((0.25*GAMMAprime)*GAMMAprime)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_big_sqrt_VP_dV_s_b = (deriv_sqrt_0_d0*(((0.25*GAMMAprime)*d_GAMMAprime_dV_s_b+0.25*d_GAMMAprime_dV_s_b*GAMMAprime)));
d_big_sqrt_VP_dV_d_b = (deriv_sqrt_0_d0*(((0.25*GAMMAprime)*d_GAMMAprime_dV_d_b+0.25*d_GAMMAprime_dV_d_b*GAMMAprime)));
d_big_sqrt_VP_dV_g_b = (deriv_sqrt_0_d0*((d_VGprime_dV_g_b+((0.25*GAMMAprime)*d_GAMMAprime_dV_g_b+0.25*d_GAMMAprime_dV_g_b*GAMMAprime))));
big_sqrt_VP = value_sqrt_0;
}

d_VP_dV_s_b = (-(GAMMAprime*(d_big_sqrt_VP_dV_s_b-0.5*d_GAMMAprime_dV_s_b)+d_GAMMAprime_dV_s_b*(big_sqrt_VP-(0.5*GAMMAprime))));
d_VP_dV_d_b = (-(GAMMAprime*(d_big_sqrt_VP_dV_d_b-0.5*d_GAMMAprime_dV_d_b)+d_GAMMAprime_dV_d_b*(big_sqrt_VP-(0.5*GAMMAprime))));
d_VP_dV_g_b = (d_VGprime_dV_g_b-(GAMMAprime*(d_big_sqrt_VP_dV_g_b-0.5*d_GAMMAprime_dV_g_b)+d_GAMMAprime_dV_g_b*(big_sqrt_VP-(0.5*GAMMAprime))));
VP = ((VGprime-PHI_T)-(GAMMAprime*(big_sqrt_VP-(0.5*GAMMAprime))));

d_tmp1_dV_s_b = (d_VP_dV_s_b-d_VS_dV_s_b)*inv_Vt;
d_tmp1_dV_d_b = (d_VP_dV_d_b-d_VS_dV_d_b)*inv_Vt;
d_tmp1_dV_g_b = d_VP_dV_g_b*inv_Vt;
tmp1 = ((VP-VS)*inv_Vt);
if ((tmp1>(-0.35)))
{
{
double value_log_0 = log((tmp1+1.6));
double  deriv_log_0_d0 = (1.0/(tmp1+1.6));

d_z0_dV_s_b = (-2.0*(d_tmp1_dV_s_b-(deriv_log_0_d0*(d_tmp1_dV_s_b)))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
d_z0_dV_d_b = (-2.0*(d_tmp1_dV_d_b-(deriv_log_0_d0*(d_tmp1_dV_d_b)))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
d_z0_dV_g_b = (-2.0*(d_tmp1_dV_g_b-(deriv_log_0_d0*(d_tmp1_dV_g_b)))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
z0 = (2.0/((1.3+tmp1)-value_log_0));
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);

d_zk_dV_s_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_s_b-(2.0+z0)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_z0_dV_s_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_d_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_d_b-(2.0+z0)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_z0_dV_d_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_g_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_g_b-(2.0+z0)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_z0_dV_g_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);

d_yk_dV_s_b = (((2.0+zk)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_zk_dV_s_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_s_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_d_b = (((2.0+zk)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_zk_dV_d_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_d_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_g_b = (((2.0+zk)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_zk_dV_g_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_g_b)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-15.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;

d_z0_dV_s_b = (deriv_exp_0_d0*((-d_tmp1_dV_s_b)));
d_z0_dV_d_b = (deriv_exp_0_d0*((-d_tmp1_dV_d_b)));
d_z0_dV_g_b = (deriv_exp_0_d0*((-d_tmp1_dV_g_b)));
z0 = (1.55+value_exp_0);
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);

d_zk_dV_s_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_s_b-(2.0+z0)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_z0_dV_s_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_d_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_d_b-(2.0+z0)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_z0_dV_d_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_g_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_g_b-(2.0+z0)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_z0_dV_g_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);

d_yk_dV_s_b = (((2.0+zk)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_zk_dV_s_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_s_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_d_b = (((2.0+zk)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_zk_dV_d_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_d_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_g_b = (((2.0+zk)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_zk_dV_g_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_g_b)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-23.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;

d_yk_dV_s_b = (-(deriv_exp_0_d0*((-d_tmp1_dV_s_b)))/(2.0+value_exp_0)/(2.0+value_exp_0));
d_yk_dV_d_b = (-(deriv_exp_0_d0*((-d_tmp1_dV_d_b)))/(2.0+value_exp_0)/(2.0+value_exp_0));
d_yk_dV_g_b = (-(deriv_exp_0_d0*((-d_tmp1_dV_g_b)))/(2.0+value_exp_0)/(2.0+value_exp_0));
yk = (1.0/(2.0+value_exp_0));
}
}
else
{
{
double value_exp_0 = exp(tmp1);
double  deriv_exp_0_d0 = value_exp_0;

d_yk_dV_s_b = (deriv_exp_0_d0*(d_tmp1_dV_s_b));
d_yk_dV_d_b = (deriv_exp_0_d0*(d_tmp1_dV_d_b));
d_yk_dV_g_b = (deriv_exp_0_d0*(d_tmp1_dV_g_b));
yk = (value_exp_0+1E-64);
}
}
}
}

d_if__dV_s_b = (yk*d_yk_dV_s_b+d_yk_dV_s_b*(1.0+yk));
d_if__dV_d_b = (yk*d_yk_dV_d_b+d_yk_dV_d_b*(1.0+yk));
d_if__dV_g_b = (yk*d_yk_dV_g_b+d_yk_dV_g_b*(1.0+yk));
if_ = (yk*(1.0+yk));
{
double value_sqrt_0 = sqrt(if_);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_if_dV_s_b = (deriv_sqrt_0_d0*(d_if__dV_s_b));
d_sqrt_if_dV_d_b = (deriv_sqrt_0_d0*(d_if__dV_d_b));
d_sqrt_if_dV_g_b = (deriv_sqrt_0_d0*(d_if__dV_g_b));
sqrt_if = value_sqrt_0;
}

d_dif_dv_dV_s_b = d_yk_dV_s_b;
d_dif_dv_dV_d_b = d_yk_dV_d_b;
d_dif_dv_dV_g_b = d_yk_dV_g_b;
dif_dv = yk;
Vt_Vc = (Vt/Vc);
{
double value_sqrt_0 = sqrt((0.25+(sqrt_if*Vt_Vc)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_VDSS_sqrt_dV_s_b = (deriv_sqrt_0_d0*(d_sqrt_if_dV_s_b*Vt_Vc));
d_VDSS_sqrt_dV_d_b = (deriv_sqrt_0_d0*(d_sqrt_if_dV_d_b*Vt_Vc));
d_VDSS_sqrt_dV_g_b = (deriv_sqrt_0_d0*(d_sqrt_if_dV_g_b*Vt_Vc));
VDSS_sqrt = value_sqrt_0;
}

d_VDSS_dV_s_b = Vc*d_VDSS_sqrt_dV_s_b;
d_VDSS_dV_d_b = Vc*d_VDSS_sqrt_dV_d_b;
d_VDSS_dV_g_b = Vc*d_VDSS_sqrt_dV_g_b;
VDSS = (Vc*(VDSS_sqrt-0.5));

d_Vds_dV_d_b = 0.5*(d_VD_dV_d_b-d_VS_dV_d_b);
d_Vds_dV_s_b = 0.5*(d_VD_dV_s_b-d_VS_dV_s_b);
Vds = (0.5*(VD-VS));

d_deltaV_2_dV_s_b = Vt_Vt_16*(model_.LAMBDA)*(d_sqrt_if_dV_s_b-d_VDSS_dV_s_b*inv_Vt);
d_deltaV_2_dV_d_b = Vt_Vt_16*(model_.LAMBDA)*(d_sqrt_if_dV_d_b-d_VDSS_dV_d_b*inv_Vt);
d_deltaV_2_dV_g_b = Vt_Vt_16*(model_.LAMBDA)*(d_sqrt_if_dV_g_b-d_VDSS_dV_g_b*inv_Vt);
deltaV_2 = (Vt_Vt_16*(((model_.LAMBDA)*(sqrt_if-(VDSS*inv_Vt)))+15.625e-3));
{
double value_sqrt_0 = sqrt(((VDSS*VDSS)+deltaV_2));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_VDSS_deltaV_dV_s_b = (deriv_sqrt_0_d0*(((VDSS*d_VDSS_dV_s_b+d_VDSS_dV_s_b*VDSS)+d_deltaV_2_dV_s_b)));
d_sqrt_VDSS_deltaV_dV_d_b = (deriv_sqrt_0_d0*(((VDSS*d_VDSS_dV_d_b+d_VDSS_dV_d_b*VDSS)+d_deltaV_2_dV_d_b)));
d_sqrt_VDSS_deltaV_dV_g_b = (deriv_sqrt_0_d0*(((VDSS*d_VDSS_dV_g_b+d_VDSS_dV_g_b*VDSS)+d_deltaV_2_dV_g_b)));
sqrt_VDSS_deltaV = value_sqrt_0;
}
{
double value_sqrt_0 = sqrt((((Vds-VDSS)*(Vds-VDSS))+deltaV_2));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_Vds_VDSS_deltaV_dV_g_b = (deriv_sqrt_0_d0*((((Vds-VDSS)*(-d_VDSS_dV_g_b)+(-d_VDSS_dV_g_b)*(Vds-VDSS))+d_deltaV_2_dV_g_b)));
d_sqrt_Vds_VDSS_deltaV_dV_d_b = (deriv_sqrt_0_d0*((((Vds-VDSS)*(d_Vds_dV_d_b-d_VDSS_dV_d_b)+(d_Vds_dV_d_b-d_VDSS_dV_d_b)*(Vds-VDSS))+d_deltaV_2_dV_d_b)));
d_sqrt_Vds_VDSS_deltaV_dV_s_b = (deriv_sqrt_0_d0*((((Vds-VDSS)*(d_Vds_dV_s_b-d_VDSS_dV_s_b)+(d_Vds_dV_s_b-d_VDSS_dV_s_b)*(Vds-VDSS))+d_deltaV_2_dV_s_b)));
sqrt_Vds_VDSS_deltaV = value_sqrt_0;
}

d_Vip_dV_s_b = (d_sqrt_VDSS_deltaV_dV_s_b-d_sqrt_Vds_VDSS_deltaV_dV_s_b);
d_Vip_dV_d_b = (d_sqrt_VDSS_deltaV_dV_d_b-d_sqrt_Vds_VDSS_deltaV_dV_d_b);
d_Vip_dV_g_b = (d_sqrt_VDSS_deltaV_dV_g_b-d_sqrt_Vds_VDSS_deltaV_dV_g_b);
Vip = (sqrt_VDSS_deltaV-sqrt_Vds_VDSS_deltaV);
{
double value_log_0 = log(if_);
double value_sqrt_1 = sqrt((0.25+((sqrt_if-(0.75*value_log_0))*Vt_Vc)));
double  deriv_log_0_d0 = (1.0/if_);
double  deriv_sqrt_1_d0 = (0.5/value_sqrt_1);

d_VDSSprime_sqrt_dV_s_b = (deriv_sqrt_1_d0*((d_sqrt_if_dV_s_b-0.75*(deriv_log_0_d0*(d_if__dV_s_b)))*Vt_Vc));
d_VDSSprime_sqrt_dV_d_b = (deriv_sqrt_1_d0*((d_sqrt_if_dV_d_b-0.75*(deriv_log_0_d0*(d_if__dV_d_b)))*Vt_Vc));
d_VDSSprime_sqrt_dV_g_b = (deriv_sqrt_1_d0*((d_sqrt_if_dV_g_b-0.75*(deriv_log_0_d0*(d_if__dV_g_b)))*Vt_Vc));
VDSSprime_sqrt = value_sqrt_1;
}

d_VDSSprime_dV_s_b = Vc*d_VDSSprime_sqrt_dV_s_b;
d_VDSSprime_dV_d_b = Vc*d_VDSSprime_sqrt_dV_d_b;
d_VDSSprime_dV_g_b = Vc*d_VDSSprime_sqrt_dV_g_b;
VDSSprime = ((Vc*(VDSSprime_sqrt-0.5))+log_Vc_Vt);

d_Vdsprime_dV_g_b = (-d_VDSSprime_dV_g_b);
d_Vdsprime_dV_d_b = (d_Vds_dV_d_b-d_VDSSprime_dV_d_b);
d_Vdsprime_dV_s_b = (d_Vds_dV_s_b-d_VDSSprime_dV_s_b);
Vdsprime = (Vds-VDSSprime);
{
double value_sqrt_0 = sqrt(((VDSSprime*VDSSprime)+deltaV_2));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_VDSSprime_deltaV_dV_s_b = (deriv_sqrt_0_d0*(((VDSSprime*d_VDSSprime_dV_s_b+d_VDSSprime_dV_s_b*VDSSprime)+d_deltaV_2_dV_s_b)));
d_sqrt_VDSSprime_deltaV_dV_d_b = (deriv_sqrt_0_d0*(((VDSSprime*d_VDSSprime_dV_d_b+d_VDSSprime_dV_d_b*VDSSprime)+d_deltaV_2_dV_d_b)));
d_sqrt_VDSSprime_deltaV_dV_g_b = (deriv_sqrt_0_d0*(((VDSSprime*d_VDSSprime_dV_g_b+d_VDSSprime_dV_g_b*VDSSprime)+d_deltaV_2_dV_g_b)));
sqrt_VDSSprime_deltaV = value_sqrt_0;
}
{
double value_sqrt_0 = sqrt(((Vdsprime*Vdsprime)+deltaV_2));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_Vds_VDSSprime_deltaV_dV_g_b = (deriv_sqrt_0_d0*(((Vdsprime*d_Vdsprime_dV_g_b+d_Vdsprime_dV_g_b*Vdsprime)+d_deltaV_2_dV_g_b)));
d_sqrt_Vds_VDSSprime_deltaV_dV_d_b = (deriv_sqrt_0_d0*(((Vdsprime*d_Vdsprime_dV_d_b+d_Vdsprime_dV_d_b*Vdsprime)+d_deltaV_2_dV_d_b)));
d_sqrt_Vds_VDSSprime_deltaV_dV_s_b = (deriv_sqrt_0_d0*(((Vdsprime*d_Vdsprime_dV_s_b+d_Vdsprime_dV_s_b*Vdsprime)+d_deltaV_2_dV_s_b)));
sqrt_Vds_VDSSprime_deltaV = value_sqrt_0;
}

d_tmp1_dV_s_b = ((((d_VP_dV_s_b-d_Vds_dV_s_b)-d_VS_dV_s_b)-d_sqrt_VDSSprime_deltaV_dV_s_b)+d_sqrt_Vds_VDSSprime_deltaV_dV_s_b)*inv_Vt;
d_tmp1_dV_d_b = ((((d_VP_dV_d_b-d_Vds_dV_d_b)-d_VS_dV_d_b)-d_sqrt_VDSSprime_deltaV_dV_d_b)+d_sqrt_Vds_VDSSprime_deltaV_dV_d_b)*inv_Vt;
d_tmp1_dV_g_b = ((d_VP_dV_g_b-d_sqrt_VDSSprime_deltaV_dV_g_b)+d_sqrt_Vds_VDSSprime_deltaV_dV_g_b)*inv_Vt;
tmp1 = (((((VP-Vds)-VS)-sqrt_VDSSprime_deltaV)+sqrt_Vds_VDSSprime_deltaV)*inv_Vt);
if ((tmp1>(-0.35)))
{
{
double value_log_0 = log((tmp1+1.6));
double  deriv_log_0_d0 = (1.0/(tmp1+1.6));

d_z0_dV_s_b = (-2.0*(d_tmp1_dV_s_b-(deriv_log_0_d0*(d_tmp1_dV_s_b)))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
d_z0_dV_d_b = (-2.0*(d_tmp1_dV_d_b-(deriv_log_0_d0*(d_tmp1_dV_d_b)))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
d_z0_dV_g_b = (-2.0*(d_tmp1_dV_g_b-(deriv_log_0_d0*(d_tmp1_dV_g_b)))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
z0 = (2.0/((1.3+tmp1)-value_log_0));
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);

d_zk_dV_s_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_s_b-(2.0+z0)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_z0_dV_s_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_d_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_d_b-(2.0+z0)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_z0_dV_d_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_g_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_g_b-(2.0+z0)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_z0_dV_g_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);

d_yk_dV_s_b = (((2.0+zk)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_zk_dV_s_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_s_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_d_b = (((2.0+zk)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_zk_dV_d_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_d_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_g_b = (((2.0+zk)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_zk_dV_g_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_g_b)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-15.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;

d_z0_dV_s_b = (deriv_exp_0_d0*((-d_tmp1_dV_s_b)));
d_z0_dV_d_b = (deriv_exp_0_d0*((-d_tmp1_dV_d_b)));
d_z0_dV_g_b = (deriv_exp_0_d0*((-d_tmp1_dV_g_b)));
z0 = (1.55+value_exp_0);
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);

d_zk_dV_s_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_s_b-(2.0+z0)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_z0_dV_s_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_d_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_d_b-(2.0+z0)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_z0_dV_d_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_g_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_g_b-(2.0+z0)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_z0_dV_g_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);

d_yk_dV_s_b = (((2.0+zk)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_zk_dV_s_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_s_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_d_b = (((2.0+zk)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_zk_dV_d_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_d_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_g_b = (((2.0+zk)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_zk_dV_g_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_g_b)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-23.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;

d_yk_dV_s_b = (-(deriv_exp_0_d0*((-d_tmp1_dV_s_b)))/(2.0+value_exp_0)/(2.0+value_exp_0));
d_yk_dV_d_b = (-(deriv_exp_0_d0*((-d_tmp1_dV_d_b)))/(2.0+value_exp_0)/(2.0+value_exp_0));
d_yk_dV_g_b = (-(deriv_exp_0_d0*((-d_tmp1_dV_g_b)))/(2.0+value_exp_0)/(2.0+value_exp_0));
yk = (1.0/(2.0+value_exp_0));
}
}
else
{
{
double value_exp_0 = exp(tmp1);
double  deriv_exp_0_d0 = value_exp_0;

d_yk_dV_s_b = (deriv_exp_0_d0*(d_tmp1_dV_s_b));
d_yk_dV_d_b = (deriv_exp_0_d0*(d_tmp1_dV_d_b));
d_yk_dV_g_b = (deriv_exp_0_d0*(d_tmp1_dV_g_b));
yk = (value_exp_0+1E-64);
}
}
}
}

d_irprime_dV_s_b = (yk*d_yk_dV_s_b+d_yk_dV_s_b*(1.0+yk));
d_irprime_dV_d_b = (yk*d_yk_dV_d_b+d_yk_dV_d_b*(1.0+yk));
d_irprime_dV_g_b = (yk*d_yk_dV_g_b+d_yk_dV_g_b*(1.0+yk));
irprime = (yk*(1.0+yk));
{
double value_sqrt_0 = sqrt(irprime);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
sqrt_irprime = value_sqrt_0;
}

d_dirprime_dv_dV_s_b = d_yk_dV_s_b;
d_dirprime_dv_dV_d_b = d_yk_dV_d_b;
d_dirprime_dv_dV_g_b = d_yk_dV_g_b;
dirprime_dv = yk;
{
double value_log_0 = log((1.0+((Vds-Vip)/Lc_UCRIT)));
double  deriv_log_0_d0 = (1.0/(1.0+((Vds-Vip)/Lc_UCRIT)));

d_deltaL_dV_g_b = Lc_LAMBDA*(deriv_log_0_d0*(((-d_Vip_dV_g_b)/Lc_UCRIT)));
d_deltaL_dV_d_b = Lc_LAMBDA*(deriv_log_0_d0*(((d_Vds_dV_d_b-d_Vip_dV_d_b)/Lc_UCRIT)));
d_deltaL_dV_s_b = Lc_LAMBDA*(deriv_log_0_d0*(((d_Vds_dV_s_b-d_Vip_dV_s_b)/Lc_UCRIT)));
deltaL = (Lc_LAMBDA*value_log_0);
}

d_Lprime_dV_g_b = ((-d_deltaL_dV_g_b)+d_Vip_dV_g_b*inv_UCRIT);
d_Lprime_dV_d_b = ((-d_deltaL_dV_d_b)+(d_Vds_dV_d_b+d_Vip_dV_d_b)*inv_UCRIT);
d_Lprime_dV_s_b = ((-d_deltaL_dV_s_b)+(d_Vds_dV_s_b+d_Vip_dV_s_b)*inv_UCRIT);
Lprime = ((Leff-deltaL)+((Vds+Vip)*inv_UCRIT));
Lmin = (0.1*Leff);
{
double value_sqrt_0 = sqrt(((Lprime*Lprime)+(Lmin*Lmin)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_Lprime_Lmin_dV_g_b = (deriv_sqrt_0_d0*((Lprime*d_Lprime_dV_g_b+d_Lprime_dV_g_b*Lprime)));
d_sqrt_Lprime_Lmin_dV_d_b = (deriv_sqrt_0_d0*((Lprime*d_Lprime_dV_d_b+d_Lprime_dV_d_b*Lprime)));
d_sqrt_Lprime_Lmin_dV_s_b = (deriv_sqrt_0_d0*((Lprime*d_Lprime_dV_s_b+d_Lprime_dV_s_b*Lprime)));
sqrt_Lprime_Lmin = value_sqrt_0;
}

d_Leq_dV_g_b = 0.5*(d_Lprime_dV_g_b+d_sqrt_Lprime_Lmin_dV_g_b);
d_Leq_dV_d_b = 0.5*(d_Lprime_dV_d_b+d_sqrt_Lprime_Lmin_dV_d_b);
d_Leq_dV_s_b = 0.5*(d_Lprime_dV_s_b+d_sqrt_Lprime_Lmin_dV_s_b);
Leq = (0.5*(Lprime+sqrt_Lprime_Lmin));

d_tmp1_dV_s_b = (d_VP_dV_s_b-d_VD_dV_s_b)*inv_Vt;
d_tmp1_dV_d_b = (d_VP_dV_d_b-d_VD_dV_d_b)*inv_Vt;
d_tmp1_dV_g_b = d_VP_dV_g_b*inv_Vt;
tmp1 = ((VP-VD)*inv_Vt);
if ((tmp1>(-0.35)))
{
{
double value_log_0 = log((tmp1+1.6));
double  deriv_log_0_d0 = (1.0/(tmp1+1.6));

d_z0_dV_s_b = (-2.0*(d_tmp1_dV_s_b-(deriv_log_0_d0*(d_tmp1_dV_s_b)))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
d_z0_dV_d_b = (-2.0*(d_tmp1_dV_d_b-(deriv_log_0_d0*(d_tmp1_dV_d_b)))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
d_z0_dV_g_b = (-2.0*(d_tmp1_dV_g_b-(deriv_log_0_d0*(d_tmp1_dV_g_b)))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
z0 = (2.0/((1.3+tmp1)-value_log_0));
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);

d_zk_dV_s_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_s_b-(2.0+z0)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_z0_dV_s_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_d_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_d_b-(2.0+z0)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_z0_dV_d_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_g_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_g_b-(2.0+z0)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_z0_dV_g_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);

d_yk_dV_s_b = (((2.0+zk)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_zk_dV_s_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_s_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_d_b = (((2.0+zk)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_zk_dV_d_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_d_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_g_b = (((2.0+zk)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_zk_dV_g_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_g_b)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-15.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;

d_z0_dV_s_b = (deriv_exp_0_d0*((-d_tmp1_dV_s_b)));
d_z0_dV_d_b = (deriv_exp_0_d0*((-d_tmp1_dV_d_b)));
d_z0_dV_g_b = (deriv_exp_0_d0*((-d_tmp1_dV_g_b)));
z0 = (1.55+value_exp_0);
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);

d_zk_dV_s_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_s_b-(2.0+z0)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_z0_dV_s_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_d_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_d_b-(2.0+z0)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_z0_dV_d_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
d_zk_dV_g_b = ((((1.0+tmp1)+value_log_0)*d_z0_dV_g_b-(2.0+z0)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_z0_dV_g_b))))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);

d_yk_dV_s_b = (((2.0+zk)*(d_tmp1_dV_s_b+(deriv_log_0_d0*(d_zk_dV_s_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_s_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_d_b = (((2.0+zk)*(d_tmp1_dV_d_b+(deriv_log_0_d0*(d_zk_dV_d_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_d_b)/(2.0+zk)/(2.0+zk));
d_yk_dV_g_b = (((2.0+zk)*(d_tmp1_dV_g_b+(deriv_log_0_d0*(d_zk_dV_g_b)))-((1.0+tmp1)+value_log_0)*d_zk_dV_g_b)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-23.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;

d_yk_dV_s_b = (-(deriv_exp_0_d0*((-d_tmp1_dV_s_b)))/(2.0+value_exp_0)/(2.0+value_exp_0));
d_yk_dV_d_b = (-(deriv_exp_0_d0*((-d_tmp1_dV_d_b)))/(2.0+value_exp_0)/(2.0+value_exp_0));
d_yk_dV_g_b = (-(deriv_exp_0_d0*((-d_tmp1_dV_g_b)))/(2.0+value_exp_0)/(2.0+value_exp_0));
yk = (1.0/(2.0+value_exp_0));
}
}
else
{
{
double value_exp_0 = exp(tmp1);
double  deriv_exp_0_d0 = value_exp_0;

d_yk_dV_s_b = (deriv_exp_0_d0*(d_tmp1_dV_s_b));
d_yk_dV_d_b = (deriv_exp_0_d0*(d_tmp1_dV_d_b));
d_yk_dV_g_b = (deriv_exp_0_d0*(d_tmp1_dV_g_b));
yk = (value_exp_0+1E-64);
}
}
}
}

d_ir_dV_s_b = (yk*d_yk_dV_s_b+d_yk_dV_s_b*(1.0+yk));
d_ir_dV_d_b = (yk*d_yk_dV_d_b+d_yk_dV_d_b*(1.0+yk));
d_ir_dV_g_b = (yk*d_yk_dV_g_b+d_yk_dV_g_b*(1.0+yk));
ir = (yk*(1.0+yk));
{
double value_sqrt_0 = sqrt(ir);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
sqrt_ir = value_sqrt_0;
}

d_dir_dv_dV_s_b = d_yk_dV_s_b;
d_dir_dv_dV_d_b = d_yk_dV_d_b;
d_dir_dv_dV_g_b = d_yk_dV_g_b;
dir_dv = yk;

d_sif2_dV_s_b = d_if__dV_s_b;
d_sif2_dV_d_b = d_if__dV_d_b;
d_sif2_dV_g_b = d_if__dV_g_b;
sif2 = (0.25+if_);

d_sir2_dV_s_b = d_ir_dV_s_b;
d_sir2_dV_d_b = d_ir_dV_d_b;
d_sir2_dV_g_b = d_ir_dV_g_b;
sir2 = (0.25+ir);
{
double value_sqrt_0 = sqrt(sif2);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sif_dV_s_b = (deriv_sqrt_0_d0*(d_sif2_dV_s_b));
d_sif_dV_d_b = (deriv_sqrt_0_d0*(d_sif2_dV_d_b));
d_sif_dV_g_b = (deriv_sqrt_0_d0*(d_sif2_dV_g_b));
sif = value_sqrt_0;
}
{
double value_sqrt_0 = sqrt(sir2);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sir_dV_s_b = (deriv_sqrt_0_d0*(d_sir2_dV_s_b));
d_sir_dV_d_b = (deriv_sqrt_0_d0*(d_sir2_dV_d_b));
d_sir_dV_g_b = (deriv_sqrt_0_d0*(d_sir2_dV_g_b));
sir = value_sqrt_0;
}

d_sif_sir_2_dV_s_b = ((sif+sir)*(d_sif_dV_s_b+d_sir_dV_s_b)+(d_sif_dV_s_b+d_sir_dV_s_b)*(sif+sir));
d_sif_sir_2_dV_d_b = ((sif+sir)*(d_sif_dV_d_b+d_sir_dV_d_b)+(d_sif_dV_d_b+d_sir_dV_d_b)*(sif+sir));
d_sif_sir_2_dV_g_b = ((sif+sir)*(d_sif_dV_g_b+d_sir_dV_g_b)+(d_sif_dV_g_b+d_sir_dV_g_b)*(sif+sir));
sif_sir_2 = ((sif+sir)*(sif+sir));

d_VP_PHI_eps_dV_s_b = d_VP_dV_s_b;
d_VP_PHI_eps_dV_d_b = d_VP_dV_d_b;
d_VP_PHI_eps_dV_g_b = d_VP_dV_g_b;
VP_PHI_eps = ((VP+PHI_T)+1.0e-6);
{
double value_sqrt_0 = sqrt(VP_PHI_eps);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_PHI_VP_2_dV_s_b = 2.0*(deriv_sqrt_0_d0*(d_VP_PHI_eps_dV_s_b));
d_sqrt_PHI_VP_2_dV_d_b = 2.0*(deriv_sqrt_0_d0*(d_VP_PHI_eps_dV_d_b));
d_sqrt_PHI_VP_2_dV_g_b = 2.0*(deriv_sqrt_0_d0*(d_VP_PHI_eps_dV_g_b));
sqrt_PHI_VP_2 = (2.0*value_sqrt_0);
}

d_n_1_dV_s_b = (-GAMMA_S*d_sqrt_PHI_VP_2_dV_s_b/sqrt_PHI_VP_2/sqrt_PHI_VP_2);
d_n_1_dV_d_b = (-GAMMA_S*d_sqrt_PHI_VP_2_dV_d_b/sqrt_PHI_VP_2/sqrt_PHI_VP_2);
d_n_1_dV_g_b = (-GAMMA_S*d_sqrt_PHI_VP_2_dV_g_b/sqrt_PHI_VP_2/sqrt_PHI_VP_2);
n_1 = (GAMMA_S/sqrt_PHI_VP_2);

d_n_1_n_dV_s_b = (-GAMMA_S*d_sqrt_PHI_VP_2_dV_s_b/(sqrt_PHI_VP_2+GAMMA_S)/(sqrt_PHI_VP_2+GAMMA_S));
d_n_1_n_dV_d_b = (-GAMMA_S*d_sqrt_PHI_VP_2_dV_d_b/(sqrt_PHI_VP_2+GAMMA_S)/(sqrt_PHI_VP_2+GAMMA_S));
d_n_1_n_dV_g_b = (-GAMMA_S*d_sqrt_PHI_VP_2_dV_g_b/(sqrt_PHI_VP_2+GAMMA_S)/(sqrt_PHI_VP_2+GAMMA_S));
n_1_n = (GAMMA_S/(sqrt_PHI_VP_2+GAMMA_S));

d_qi_dV_s_b = (((-(1.0+n_1))*Vt)*(((sif+sir)*(0.66666666+0.66666666)*((d_sir2_dV_s_b+(sir*d_sif_dV_s_b+d_sir_dV_s_b*sif))+d_sif2_dV_s_b)-((0.66666666+0.66666666)*((sir2+(sir*sif))+sif2))*(d_sif_dV_s_b+d_sir_dV_s_b))/(sif+sir)/(sif+sir))+(-d_n_1_dV_s_b)*Vt*((((0.66666666+0.66666666)*((sir2+(sir*sif))+sif2))/(sif+sir))-1.0));
d_qi_dV_d_b = (((-(1.0+n_1))*Vt)*(((sif+sir)*(0.66666666+0.66666666)*((d_sir2_dV_d_b+(sir*d_sif_dV_d_b+d_sir_dV_d_b*sif))+d_sif2_dV_d_b)-((0.66666666+0.66666666)*((sir2+(sir*sif))+sif2))*(d_sif_dV_d_b+d_sir_dV_d_b))/(sif+sir)/(sif+sir))+(-d_n_1_dV_d_b)*Vt*((((0.66666666+0.66666666)*((sir2+(sir*sif))+sif2))/(sif+sir))-1.0));
d_qi_dV_g_b = (((-(1.0+n_1))*Vt)*(((sif+sir)*(0.66666666+0.66666666)*((d_sir2_dV_g_b+(sir*d_sif_dV_g_b+d_sir_dV_g_b*sif))+d_sif2_dV_g_b)-((0.66666666+0.66666666)*((sir2+(sir*sif))+sif2))*(d_sif_dV_g_b+d_sir_dV_g_b))/(sif+sir)/(sif+sir))+(-d_n_1_dV_g_b)*Vt*((((0.66666666+0.66666666)*((sir2+(sir*sif))+sif2))/(sif+sir))-1.0));
qi = (((-(1.0+n_1))*Vt)*((((0.66666666+0.66666666)*((sir2+(sir*sif))+sif2))/(sif+sir))-1.0));

d_qb_dV_s_b = (((-0.5)*GAMMA_S)*d_sqrt_PHI_VP_2_dV_s_b-(n_1_n*d_qi_dV_s_b+d_n_1_n_dV_s_b*qi));
d_qb_dV_d_b = (((-0.5)*GAMMA_S)*d_sqrt_PHI_VP_2_dV_d_b-(n_1_n*d_qi_dV_d_b+d_n_1_n_dV_d_b*qi));
d_qb_dV_g_b = (((-0.5)*GAMMA_S)*d_sqrt_PHI_VP_2_dV_g_b-(n_1_n*d_qi_dV_g_b+d_n_1_n_dV_g_b*qi));
qb = ((((-0.5)*GAMMA_S)*sqrt_PHI_VP_2)-(n_1_n*qi));
if (((model_.E0)==0.0))
{
{
double value_sqrt_0 = sqrt(((VP*VP)+Vt_Vt_2));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_VP_Vt_dV_s_b = (deriv_sqrt_0_d0*((VP*d_VP_dV_s_b+d_VP_dV_s_b*VP)));
d_sqrt_VP_Vt_dV_d_b = (deriv_sqrt_0_d0*((VP*d_VP_dV_d_b+d_VP_dV_d_b*VP)));
d_sqrt_VP_Vt_dV_g_b = (deriv_sqrt_0_d0*((VP*d_VP_dV_g_b+d_VP_dV_g_b*VP)));
sqrt_VP_Vt = value_sqrt_0;
}

d_VPprime_dV_s_b = 0.5*(d_VP_dV_s_b+d_sqrt_VP_Vt_dV_s_b);
d_VPprime_dV_d_b = 0.5*(d_VP_dV_d_b+d_sqrt_VP_Vt_dV_d_b);
d_VPprime_dV_g_b = 0.5*(d_VP_dV_g_b+d_sqrt_VP_Vt_dV_g_b);
VPprime = (0.5*(VP+sqrt_VP_Vt));

d_THETA_VP_1_dV_s_b = (model_.THETA)*d_VPprime_dV_s_b;
d_THETA_VP_1_dV_d_b = (model_.THETA)*d_VPprime_dV_d_b;
d_THETA_VP_1_dV_g_b = (model_.THETA)*d_VPprime_dV_g_b;
THETA_VP_1 = (1.0+((model_.THETA)*VPprime));

d_beta_dV_g_b = (-KP_Weff*(Leq*d_THETA_VP_1_dV_g_b+d_Leq_dV_g_b*THETA_VP_1)/(Leq*THETA_VP_1)/(Leq*THETA_VP_1));
d_beta_dV_d_b = (-KP_Weff*(Leq*d_THETA_VP_1_dV_d_b+d_Leq_dV_d_b*THETA_VP_1)/(Leq*THETA_VP_1)/(Leq*THETA_VP_1));
d_beta_dV_s_b = (-KP_Weff*(Leq*d_THETA_VP_1_dV_s_b+d_Leq_dV_s_b*THETA_VP_1)/(Leq*THETA_VP_1)/(Leq*THETA_VP_1));
beta = (KP_Weff/(Leq*THETA_VP_1));
}
else
{
if (((qb+(eta_qi*qi))>0.0))
{

d_E0_Q_1_dV_s_b = T0*(d_qb_dV_s_b+eta_qi*d_qi_dV_s_b);
d_E0_Q_1_dV_d_b = T0*(d_qb_dV_d_b+eta_qi*d_qi_dV_d_b);
d_E0_Q_1_dV_g_b = T0*(d_qb_dV_g_b+eta_qi*d_qi_dV_g_b);
E0_Q_1 = (1.0+(T0*(qb+(eta_qi*qi))));
}
else
{

d_E0_Q_1_dV_s_b = (-T0*(d_qb_dV_s_b+eta_qi*d_qi_dV_s_b));
d_E0_Q_1_dV_d_b = (-T0*(d_qb_dV_d_b+eta_qi*d_qi_dV_d_b));
d_E0_Q_1_dV_g_b = (-T0*(d_qb_dV_g_b+eta_qi*d_qi_dV_g_b));
E0_Q_1 = (1.0-(T0*(qb+(eta_qi*qi))));
}
T0_GAMMA_1 = (1.0+(T0*GAMMA_sqrt_PHI));

d_beta_dV_g_b = (-(KP_Weff*T0_GAMMA_1)*(Leq*d_E0_Q_1_dV_g_b+d_Leq_dV_g_b*E0_Q_1)/(Leq*E0_Q_1)/(Leq*E0_Q_1));
d_beta_dV_d_b = (-(KP_Weff*T0_GAMMA_1)*(Leq*d_E0_Q_1_dV_d_b+d_Leq_dV_d_b*E0_Q_1)/(Leq*E0_Q_1)/(Leq*E0_Q_1));
d_beta_dV_s_b = (-(KP_Weff*T0_GAMMA_1)*(Leq*d_E0_Q_1_dV_s_b+d_Leq_dV_s_b*E0_Q_1)/(Leq*E0_Q_1)/(Leq*E0_Q_1));
beta = ((KP_Weff*T0_GAMMA_1)/(Leq*E0_Q_1));
}
{
double value_sqrt_0 = sqrt(((PHI_T+VP)+Vt_4));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_sqrt_PHI_VP_dV_s_b = (deriv_sqrt_0_d0*(d_VP_dV_s_b));
d_sqrt_PHI_VP_dV_d_b = (deriv_sqrt_0_d0*(d_VP_dV_d_b));
d_sqrt_PHI_VP_dV_g_b = (deriv_sqrt_0_d0*(d_VP_dV_g_b));
sqrt_PHI_VP = value_sqrt_0;
}

d_n_dV_s_b = (-GAMMA_S*2.0*d_sqrt_PHI_VP_dV_s_b/(2.0*sqrt_PHI_VP)/(2.0*sqrt_PHI_VP));
d_n_dV_d_b = (-GAMMA_S*2.0*d_sqrt_PHI_VP_dV_d_b/(2.0*sqrt_PHI_VP)/(2.0*sqrt_PHI_VP));
d_n_dV_g_b = (-GAMMA_S*2.0*d_sqrt_PHI_VP_dV_g_b/(2.0*sqrt_PHI_VP)/(2.0*sqrt_PHI_VP));
n = (1.0+(GAMMA_S/(2.0*sqrt_PHI_VP)));

d_if_ir_dV_s_b = (d_if__dV_s_b-d_irprime_dV_s_b);
d_if_ir_dV_d_b = (d_if__dV_d_b-d_irprime_dV_d_b);
d_if_ir_dV_g_b = (d_if__dV_g_b-d_irprime_dV_g_b);
if_ir = (if_-irprime);

d_Ispec_dV_s_b = ((Vt_Vt_2*n)*d_beta_dV_s_b+Vt_Vt_2*d_n_dV_s_b*beta);
d_Ispec_dV_d_b = ((Vt_Vt_2*n)*d_beta_dV_d_b+Vt_Vt_2*d_n_dV_d_b*beta);
d_Ispec_dV_g_b = ((Vt_Vt_2*n)*d_beta_dV_g_b+Vt_Vt_2*d_n_dV_g_b*beta);
Ispec = ((Vt_Vt_2*n)*beta);

d_Id_dV_s_b = (Ispec*d_if_ir_dV_s_b+d_Ispec_dV_s_b*if_ir);
d_Id_dV_d_b = (Ispec*d_if_ir_dV_d_b+d_Ispec_dV_d_b*if_ir);
d_Id_dV_g_b = (Ispec*d_if_ir_dV_g_b+d_Ispec_dV_g_b*if_ir);
Id = (Ispec*if_ir);
Von = (VTO_S+(GAMMAprime*(sqrt_PHI_VS-sqrt_PHI)));
Vdsat = (Vt*((2.0*sqrt_if)+4.0));
{
double value_fabs_0 = fabs(qi);
double  deriv_fabs_0_d0 = (((qi)>=0)?(+1.0):(-1.0));
Gn = (beta*value_fabs_0);
}

d_tmp1_dV_g_b = (((sqrt_GAMMAstar+sqrt_GAMMAstar)*d_GAMMAprime_dV_g_b-GAMMAprime*(d_sqrt_GAMMAstar_dV_g_b+d_sqrt_GAMMAstar_dV_g_b))/(sqrt_GAMMAstar+sqrt_GAMMAstar)/(sqrt_GAMMAstar+sqrt_GAMMAstar));
d_tmp1_dV_s_b = (((sqrt_GAMMAstar+sqrt_GAMMAstar)*d_GAMMAprime_dV_s_b-GAMMAprime*(d_sqrt_GAMMAstar_dV_s_b+d_sqrt_GAMMAstar_dV_s_b))/(sqrt_GAMMAstar+sqrt_GAMMAstar)/(sqrt_GAMMAstar+sqrt_GAMMAstar));
d_tmp1_dV_d_b = (((sqrt_GAMMAstar+sqrt_GAMMAstar)*d_GAMMAprime_dV_d_b-GAMMAprime*(d_sqrt_GAMMAstar_dV_d_b+d_sqrt_GAMMAstar_dV_d_b))/(sqrt_GAMMAstar+sqrt_GAMMAstar)/(sqrt_GAMMAstar+sqrt_GAMMAstar));
tmp1 = (GAMMAprime/(sqrt_GAMMAstar+sqrt_GAMMAstar));

d_tmp2_dV_d_b = d_tmp2_dV_s_b =  0.0;
d_tmp2_dV_g_b = ((sqrt_VGstar*d_VGprime_dV_g_b-VGprime*d_sqrt_VGstar_dV_g_b)/sqrt_VGstar/sqrt_VGstar);
tmp2 = (VGprime/sqrt_VGstar);

d_dGAMMAprime_dVD_dV_s_b = ((sqrt_PHI_VD_Vt*(((-LETA_L)*tmp1)*d_sqrt_PHI_VD_dV_s_b+(-LETA_L)*d_tmp1_dV_s_b*sqrt_PHI_VD)-(((-LETA_L)*tmp1)*sqrt_PHI_VD)*d_sqrt_PHI_VD_Vt_dV_s_b)/sqrt_PHI_VD_Vt/sqrt_PHI_VD_Vt);
d_dGAMMAprime_dVD_dV_d_b = ((sqrt_PHI_VD_Vt*(((-LETA_L)*tmp1)*d_sqrt_PHI_VD_dV_d_b+(-LETA_L)*d_tmp1_dV_d_b*sqrt_PHI_VD)-(((-LETA_L)*tmp1)*sqrt_PHI_VD)*d_sqrt_PHI_VD_Vt_dV_d_b)/sqrt_PHI_VD_Vt/sqrt_PHI_VD_Vt);
d_dGAMMAprime_dVD_dV_g_b = ((-LETA_L)*d_tmp1_dV_g_b*sqrt_PHI_VD/sqrt_PHI_VD_Vt);
dGAMMAprime_dVD = ((((-LETA_L)*tmp1)*sqrt_PHI_VD)/sqrt_PHI_VD_Vt);

d_dGAMMAprime_dVS_dV_s_b = ((sqrt_PHI_VS_Vt*(((-LETA_L)*tmp1)*d_sqrt_PHI_VS_dV_s_b+(-LETA_L)*d_tmp1_dV_s_b*sqrt_PHI_VS)-(((-LETA_L)*tmp1)*sqrt_PHI_VS)*d_sqrt_PHI_VS_Vt_dV_s_b)/sqrt_PHI_VS_Vt/sqrt_PHI_VS_Vt);
d_dGAMMAprime_dVS_dV_d_b = ((sqrt_PHI_VS_Vt*(((-LETA_L)*tmp1)*d_sqrt_PHI_VS_dV_d_b+(-LETA_L)*d_tmp1_dV_d_b*sqrt_PHI_VS)-(((-LETA_L)*tmp1)*sqrt_PHI_VS)*d_sqrt_PHI_VS_Vt_dV_d_b)/sqrt_PHI_VS_Vt/sqrt_PHI_VS_Vt);
d_dGAMMAprime_dVS_dV_g_b = ((-LETA_L)*d_tmp1_dV_g_b*sqrt_PHI_VS/sqrt_PHI_VS_Vt);
dGAMMAprime_dVS = ((((-LETA_L)*tmp1)*sqrt_PHI_VS)/sqrt_PHI_VS_Vt);
dGAMMAprime_dVG = ((((WETA_W*tmp1)*(big_sqrt_VP0-(0.5*GAMMA_S)))/(big_sqrt_VP0*sqrt_PHI_VP0))*tmp2);

d_tmp3_dV_s_b = ((big_sqrt_VP*d_VP_dV_s_b-(VP+PHI_T)*d_big_sqrt_VP_dV_s_b)/big_sqrt_VP/big_sqrt_VP);
d_tmp3_dV_d_b = ((big_sqrt_VP*d_VP_dV_d_b-(VP+PHI_T)*d_big_sqrt_VP_dV_d_b)/big_sqrt_VP/big_sqrt_VP);
d_tmp3_dV_g_b = ((big_sqrt_VP*d_VP_dV_g_b-(VP+PHI_T)*d_big_sqrt_VP_dV_g_b)/big_sqrt_VP/big_sqrt_VP);
tmp3 = ((VP+PHI_T)/big_sqrt_VP);

d_dVP_dVD_dV_s_b = ((-tmp3)*d_dGAMMAprime_dVD_dV_s_b+(-d_tmp3_dV_s_b)*dGAMMAprime_dVD);
d_dVP_dVD_dV_d_b = ((-tmp3)*d_dGAMMAprime_dVD_dV_d_b+(-d_tmp3_dV_d_b)*dGAMMAprime_dVD);
d_dVP_dVD_dV_g_b = ((-tmp3)*d_dGAMMAprime_dVD_dV_g_b+(-d_tmp3_dV_g_b)*dGAMMAprime_dVD);
dVP_dVD = ((-tmp3)*dGAMMAprime_dVD);

d_dVP_dVS_dV_s_b = ((-tmp3)*d_dGAMMAprime_dVS_dV_s_b+(-d_tmp3_dV_s_b)*dGAMMAprime_dVS);
d_dVP_dVS_dV_d_b = ((-tmp3)*d_dGAMMAprime_dVS_dV_d_b+(-d_tmp3_dV_d_b)*dGAMMAprime_dVS);
d_dVP_dVS_dV_g_b = ((-tmp3)*d_dGAMMAprime_dVS_dV_g_b+(-d_tmp3_dV_g_b)*dGAMMAprime_dVS);
dVP_dVS = ((-tmp3)*dGAMMAprime_dVS);
dVP_dVG = (((-tmp3)*dGAMMAprime_dVG)+((1.0-(GAMMAprime/(big_sqrt_VP+big_sqrt_VP)))*tmp2));

d_tmp1_dV_s_b = d_dif_dv_dV_s_b*inv_Vt;
d_tmp1_dV_d_b = d_dif_dv_dV_d_b*inv_Vt;
d_tmp1_dV_g_b = d_dif_dv_dV_g_b*inv_Vt;
tmp1 = (dif_dv*inv_Vt);

d_dif_dVD_dV_s_b = (tmp1*d_dVP_dVD_dV_s_b+d_tmp1_dV_s_b*dVP_dVD);
d_dif_dVD_dV_d_b = (tmp1*d_dVP_dVD_dV_d_b+d_tmp1_dV_d_b*dVP_dVD);
d_dif_dVD_dV_g_b = (tmp1*d_dVP_dVD_dV_g_b+d_tmp1_dV_g_b*dVP_dVD);
dif_dVD = (tmp1*dVP_dVD);

d_dif_dVS_dV_s_b = (tmp1*d_dVP_dVS_dV_s_b+d_tmp1_dV_s_b*(dVP_dVS-1.0));
d_dif_dVS_dV_d_b = (tmp1*d_dVP_dVS_dV_d_b+d_tmp1_dV_d_b*(dVP_dVS-1.0));
d_dif_dVS_dV_g_b = (tmp1*d_dVP_dVS_dV_g_b+d_tmp1_dV_g_b*(dVP_dVS-1.0));
dif_dVS = (tmp1*(dVP_dVS-1.0));
dif_dVG = (tmp1*dVP_dVG);

d_tmp1_dV_s_b = (-Vt*((4.0*VDSS_sqrt)*d_sqrt_if_dV_s_b+4.0*d_VDSS_sqrt_dV_s_b*sqrt_if)/((4.0*VDSS_sqrt)*sqrt_if)/((4.0*VDSS_sqrt)*sqrt_if));
d_tmp1_dV_d_b = (-Vt*((4.0*VDSS_sqrt)*d_sqrt_if_dV_d_b+4.0*d_VDSS_sqrt_dV_d_b*sqrt_if)/((4.0*VDSS_sqrt)*sqrt_if)/((4.0*VDSS_sqrt)*sqrt_if));
d_tmp1_dV_g_b = (-Vt*((4.0*VDSS_sqrt)*d_sqrt_if_dV_g_b+4.0*d_VDSS_sqrt_dV_g_b*sqrt_if)/((4.0*VDSS_sqrt)*sqrt_if)/((4.0*VDSS_sqrt)*sqrt_if));
tmp1 = (Vt/((4.0*VDSS_sqrt)*sqrt_if));

d_dVDSS_dVD_dV_s_b = (tmp1*d_dif_dVD_dV_s_b+d_tmp1_dV_s_b*dif_dVD);
d_dVDSS_dVD_dV_d_b = (tmp1*d_dif_dVD_dV_d_b+d_tmp1_dV_d_b*dif_dVD);
d_dVDSS_dVD_dV_g_b = (tmp1*d_dif_dVD_dV_g_b+d_tmp1_dV_g_b*dif_dVD);
dVDSS_dVD = (tmp1*dif_dVD);

d_dVDSS_dVS_dV_s_b = (tmp1*d_dif_dVS_dV_s_b+d_tmp1_dV_s_b*dif_dVS);
d_dVDSS_dVS_dV_d_b = (tmp1*d_dif_dVS_dV_d_b+d_tmp1_dV_d_b*dif_dVS);
d_dVDSS_dVS_dV_g_b = (tmp1*d_dif_dVS_dV_g_b+d_tmp1_dV_g_b*dif_dVS);
dVDSS_dVS = (tmp1*dif_dVS);
dVDSS_dVG = (tmp1*dif_dVG);

d_tmp1_dV_g_b = d_tmp1_dV_d_b = d_tmp1_dV_s_b =  0.0;
tmp1 = ((Vt_4+Vt_4)*(model_.LAMBDA));

d_tmp2_dV_s_b = (-Vt*(d_sqrt_if_dV_s_b+d_sqrt_if_dV_s_b)/(sqrt_if+sqrt_if)/(sqrt_if+sqrt_if));
d_tmp2_dV_d_b = (-Vt*(d_sqrt_if_dV_d_b+d_sqrt_if_dV_d_b)/(sqrt_if+sqrt_if)/(sqrt_if+sqrt_if));
d_tmp2_dV_g_b = (-Vt*(d_sqrt_if_dV_g_b+d_sqrt_if_dV_g_b)/(sqrt_if+sqrt_if)/(sqrt_if+sqrt_if));
tmp2 = (Vt/(sqrt_if+sqrt_if));

d_ddeltaV_dVD_dV_s_b = (tmp1*((dif_dVD*d_tmp2_dV_s_b+d_dif_dVD_dV_s_b*tmp2)-d_dVDSS_dVD_dV_s_b)+d_tmp1_dV_s_b*((dif_dVD*tmp2)-dVDSS_dVD));
d_ddeltaV_dVD_dV_d_b = (tmp1*((dif_dVD*d_tmp2_dV_d_b+d_dif_dVD_dV_d_b*tmp2)-d_dVDSS_dVD_dV_d_b)+d_tmp1_dV_d_b*((dif_dVD*tmp2)-dVDSS_dVD));
d_ddeltaV_dVD_dV_g_b = (tmp1*((dif_dVD*d_tmp2_dV_g_b+d_dif_dVD_dV_g_b*tmp2)-d_dVDSS_dVD_dV_g_b)+d_tmp1_dV_g_b*((dif_dVD*tmp2)-dVDSS_dVD));
ddeltaV_dVD = (tmp1*((dif_dVD*tmp2)-dVDSS_dVD));

d_ddeltaV_dVS_dV_s_b = (tmp1*((dif_dVS*d_tmp2_dV_s_b+d_dif_dVS_dV_s_b*tmp2)-d_dVDSS_dVS_dV_s_b)+d_tmp1_dV_s_b*((dif_dVS*tmp2)-dVDSS_dVS));
d_ddeltaV_dVS_dV_d_b = (tmp1*((dif_dVS*d_tmp2_dV_d_b+d_dif_dVS_dV_d_b*tmp2)-d_dVDSS_dVS_dV_d_b)+d_tmp1_dV_d_b*((dif_dVS*tmp2)-dVDSS_dVS));
d_ddeltaV_dVS_dV_g_b = (tmp1*((dif_dVS*d_tmp2_dV_g_b+d_dif_dVS_dV_g_b*tmp2)-d_dVDSS_dVS_dV_g_b)+d_tmp1_dV_g_b*((dif_dVS*tmp2)-dVDSS_dVS));
ddeltaV_dVS = (tmp1*((dif_dVS*tmp2)-dVDSS_dVS));
ddeltaV_dVG = (tmp1*((dif_dVG*tmp2)-dVDSS_dVG));

d_tmp1_dV_s_b = (-d_sqrt_VDSS_deltaV_dV_s_b/sqrt_VDSS_deltaV/sqrt_VDSS_deltaV);
d_tmp1_dV_d_b = (-d_sqrt_VDSS_deltaV_dV_d_b/sqrt_VDSS_deltaV/sqrt_VDSS_deltaV);
d_tmp1_dV_g_b = (-d_sqrt_VDSS_deltaV_dV_g_b/sqrt_VDSS_deltaV/sqrt_VDSS_deltaV);
tmp1 = (1.0/sqrt_VDSS_deltaV);

d_tmp2_dV_g_b = (-d_sqrt_Vds_VDSS_deltaV_dV_g_b/sqrt_Vds_VDSS_deltaV/sqrt_Vds_VDSS_deltaV);
d_tmp2_dV_d_b = (-d_sqrt_Vds_VDSS_deltaV_dV_d_b/sqrt_Vds_VDSS_deltaV/sqrt_Vds_VDSS_deltaV);
d_tmp2_dV_s_b = (-d_sqrt_Vds_VDSS_deltaV_dV_s_b/sqrt_Vds_VDSS_deltaV/sqrt_Vds_VDSS_deltaV);
tmp2 = (1.0/sqrt_Vds_VDSS_deltaV);

d_tmp3_dV_g_b = (-d_VDSS_dV_g_b);
d_tmp3_dV_d_b = (d_Vds_dV_d_b-d_VDSS_dV_d_b);
d_tmp3_dV_s_b = (d_Vds_dV_s_b-d_VDSS_dV_s_b);
tmp3 = (Vds-VDSS);

d_dVip_dVD_dV_s_b = ((((VDSS*dVDSS_dVD)+ddeltaV_dVD)*d_tmp1_dV_s_b+((VDSS*d_dVDSS_dVD_dV_s_b+d_VDSS_dV_s_b*dVDSS_dVD)+d_ddeltaV_dVD_dV_s_b)*tmp1)-(((tmp3*(0.5-dVDSS_dVD))+ddeltaV_dVD)*d_tmp2_dV_s_b+((tmp3*(-d_dVDSS_dVD_dV_s_b)+d_tmp3_dV_s_b*(0.5-dVDSS_dVD))+d_ddeltaV_dVD_dV_s_b)*tmp2));
d_dVip_dVD_dV_d_b = ((((VDSS*dVDSS_dVD)+ddeltaV_dVD)*d_tmp1_dV_d_b+((VDSS*d_dVDSS_dVD_dV_d_b+d_VDSS_dV_d_b*dVDSS_dVD)+d_ddeltaV_dVD_dV_d_b)*tmp1)-(((tmp3*(0.5-dVDSS_dVD))+ddeltaV_dVD)*d_tmp2_dV_d_b+((tmp3*(-d_dVDSS_dVD_dV_d_b)+d_tmp3_dV_d_b*(0.5-dVDSS_dVD))+d_ddeltaV_dVD_dV_d_b)*tmp2));
d_dVip_dVD_dV_g_b = ((((VDSS*dVDSS_dVD)+ddeltaV_dVD)*d_tmp1_dV_g_b+((VDSS*d_dVDSS_dVD_dV_g_b+d_VDSS_dV_g_b*dVDSS_dVD)+d_ddeltaV_dVD_dV_g_b)*tmp1)-(((tmp3*(0.5-dVDSS_dVD))+ddeltaV_dVD)*d_tmp2_dV_g_b+((tmp3*(-d_dVDSS_dVD_dV_g_b)+d_tmp3_dV_g_b*(0.5-dVDSS_dVD))+d_ddeltaV_dVD_dV_g_b)*tmp2));
dVip_dVD = ((((VDSS*dVDSS_dVD)+ddeltaV_dVD)*tmp1)-(((tmp3*(0.5-dVDSS_dVD))+ddeltaV_dVD)*tmp2));

d_dVip_dVS_dV_s_b = ((((VDSS*dVDSS_dVS)+ddeltaV_dVS)*d_tmp1_dV_s_b+((VDSS*d_dVDSS_dVS_dV_s_b+d_VDSS_dV_s_b*dVDSS_dVS)+d_ddeltaV_dVS_dV_s_b)*tmp1)-(((tmp3*((-0.5)-dVDSS_dVS))+ddeltaV_dVS)*d_tmp2_dV_s_b+((tmp3*(-d_dVDSS_dVS_dV_s_b)+d_tmp3_dV_s_b*((-0.5)-dVDSS_dVS))+d_ddeltaV_dVS_dV_s_b)*tmp2));
d_dVip_dVS_dV_d_b = ((((VDSS*dVDSS_dVS)+ddeltaV_dVS)*d_tmp1_dV_d_b+((VDSS*d_dVDSS_dVS_dV_d_b+d_VDSS_dV_d_b*dVDSS_dVS)+d_ddeltaV_dVS_dV_d_b)*tmp1)-(((tmp3*((-0.5)-dVDSS_dVS))+ddeltaV_dVS)*d_tmp2_dV_d_b+((tmp3*(-d_dVDSS_dVS_dV_d_b)+d_tmp3_dV_d_b*((-0.5)-dVDSS_dVS))+d_ddeltaV_dVS_dV_d_b)*tmp2));
d_dVip_dVS_dV_g_b = ((((VDSS*dVDSS_dVS)+ddeltaV_dVS)*d_tmp1_dV_g_b+((VDSS*d_dVDSS_dVS_dV_g_b+d_VDSS_dV_g_b*dVDSS_dVS)+d_ddeltaV_dVS_dV_g_b)*tmp1)-(((tmp3*((-0.5)-dVDSS_dVS))+ddeltaV_dVS)*d_tmp2_dV_g_b+((tmp3*(-d_dVDSS_dVS_dV_g_b)+d_tmp3_dV_g_b*((-0.5)-dVDSS_dVS))+d_ddeltaV_dVS_dV_g_b)*tmp2));
dVip_dVS = ((((VDSS*dVDSS_dVS)+ddeltaV_dVS)*tmp1)-(((tmp3*((-0.5)-dVDSS_dVS))+ddeltaV_dVS)*tmp2));
dVip_dVG = ((((VDSS*dVDSS_dVG)+ddeltaV_dVG)*tmp1)-(((tmp3*(-dVDSS_dVG))+ddeltaV_dVG)*tmp2));

d_tmp1_dV_s_b = ((((4.0*VDSSprime_sqrt)*if_)*Vt*d_sqrt_if_dV_s_b-(Vt*(sqrt_if-1.5))*((4.0*VDSSprime_sqrt)*d_if__dV_s_b+4.0*d_VDSSprime_sqrt_dV_s_b*if_))/((4.0*VDSSprime_sqrt)*if_)/((4.0*VDSSprime_sqrt)*if_));
d_tmp1_dV_d_b = ((((4.0*VDSSprime_sqrt)*if_)*Vt*d_sqrt_if_dV_d_b-(Vt*(sqrt_if-1.5))*((4.0*VDSSprime_sqrt)*d_if__dV_d_b+4.0*d_VDSSprime_sqrt_dV_d_b*if_))/((4.0*VDSSprime_sqrt)*if_)/((4.0*VDSSprime_sqrt)*if_));
d_tmp1_dV_g_b = ((((4.0*VDSSprime_sqrt)*if_)*Vt*d_sqrt_if_dV_g_b-(Vt*(sqrt_if-1.5))*((4.0*VDSSprime_sqrt)*d_if__dV_g_b+4.0*d_VDSSprime_sqrt_dV_g_b*if_))/((4.0*VDSSprime_sqrt)*if_)/((4.0*VDSSprime_sqrt)*if_));
tmp1 = ((Vt*(sqrt_if-1.5))/((4.0*VDSSprime_sqrt)*if_));

d_dVDSSprime_dVD_dV_s_b = (tmp1*d_dif_dVD_dV_s_b+d_tmp1_dV_s_b*dif_dVD);
d_dVDSSprime_dVD_dV_d_b = (tmp1*d_dif_dVD_dV_d_b+d_tmp1_dV_d_b*dif_dVD);
d_dVDSSprime_dVD_dV_g_b = (tmp1*d_dif_dVD_dV_g_b+d_tmp1_dV_g_b*dif_dVD);
dVDSSprime_dVD = (tmp1*dif_dVD);

d_dVDSSprime_dVS_dV_s_b = (tmp1*d_dif_dVS_dV_s_b+d_tmp1_dV_s_b*dif_dVS);
d_dVDSSprime_dVS_dV_d_b = (tmp1*d_dif_dVS_dV_d_b+d_tmp1_dV_d_b*dif_dVS);
d_dVDSSprime_dVS_dV_g_b = (tmp1*d_dif_dVS_dV_g_b+d_tmp1_dV_g_b*dif_dVS);
dVDSSprime_dVS = (tmp1*dif_dVS);
dVDSSprime_dVG = (tmp1*dif_dVG);

d_tmp1_dV_s_b = d_dirprime_dv_dV_s_b*inv_Vt;
d_tmp1_dV_d_b = d_dirprime_dv_dV_d_b*inv_Vt;
d_tmp1_dV_g_b = d_dirprime_dv_dV_g_b*inv_Vt;
tmp1 = (dirprime_dv*inv_Vt);

d_tmp2_dV_s_b = (-d_sqrt_VDSSprime_deltaV_dV_s_b/sqrt_VDSSprime_deltaV/sqrt_VDSSprime_deltaV);
d_tmp2_dV_d_b = (-d_sqrt_VDSSprime_deltaV_dV_d_b/sqrt_VDSSprime_deltaV/sqrt_VDSSprime_deltaV);
d_tmp2_dV_g_b = (-d_sqrt_VDSSprime_deltaV_dV_g_b/sqrt_VDSSprime_deltaV/sqrt_VDSSprime_deltaV);
tmp2 = (1.0/sqrt_VDSSprime_deltaV);

d_tmp3_dV_g_b = (-d_sqrt_Vds_VDSSprime_deltaV_dV_g_b/sqrt_Vds_VDSSprime_deltaV/sqrt_Vds_VDSSprime_deltaV);
d_tmp3_dV_d_b = (-d_sqrt_Vds_VDSSprime_deltaV_dV_d_b/sqrt_Vds_VDSSprime_deltaV/sqrt_Vds_VDSSprime_deltaV);
d_tmp3_dV_s_b = (-d_sqrt_Vds_VDSSprime_deltaV_dV_s_b/sqrt_Vds_VDSSprime_deltaV/sqrt_Vds_VDSSprime_deltaV);
tmp3 = (1.0/sqrt_Vds_VDSSprime_deltaV);

d_dirprime_dVD_dV_s_b = (tmp1*((d_dVP_dVD_dV_s_b-(((VDSSprime*dVDSSprime_dVD)+ddeltaV_dVD)*d_tmp2_dV_s_b+((VDSSprime*d_dVDSSprime_dVD_dV_s_b+d_VDSSprime_dV_s_b*dVDSSprime_dVD)+d_ddeltaV_dVD_dV_s_b)*tmp2))+(((Vdsprime*(0.5-dVDSSprime_dVD))+ddeltaV_dVD)*d_tmp3_dV_s_b+((Vdsprime*(-d_dVDSSprime_dVD_dV_s_b)+d_Vdsprime_dV_s_b*(0.5-dVDSSprime_dVD))+d_ddeltaV_dVD_dV_s_b)*tmp3))+d_tmp1_dV_s_b*(((dVP_dVD-0.5)-(((VDSSprime*dVDSSprime_dVD)+ddeltaV_dVD)*tmp2))+(((Vdsprime*(0.5-dVDSSprime_dVD))+ddeltaV_dVD)*tmp3)));
d_dirprime_dVD_dV_d_b = (tmp1*((d_dVP_dVD_dV_d_b-(((VDSSprime*dVDSSprime_dVD)+ddeltaV_dVD)*d_tmp2_dV_d_b+((VDSSprime*d_dVDSSprime_dVD_dV_d_b+d_VDSSprime_dV_d_b*dVDSSprime_dVD)+d_ddeltaV_dVD_dV_d_b)*tmp2))+(((Vdsprime*(0.5-dVDSSprime_dVD))+ddeltaV_dVD)*d_tmp3_dV_d_b+((Vdsprime*(-d_dVDSSprime_dVD_dV_d_b)+d_Vdsprime_dV_d_b*(0.5-dVDSSprime_dVD))+d_ddeltaV_dVD_dV_d_b)*tmp3))+d_tmp1_dV_d_b*(((dVP_dVD-0.5)-(((VDSSprime*dVDSSprime_dVD)+ddeltaV_dVD)*tmp2))+(((Vdsprime*(0.5-dVDSSprime_dVD))+ddeltaV_dVD)*tmp3)));
d_dirprime_dVD_dV_g_b = (tmp1*((d_dVP_dVD_dV_g_b-(((VDSSprime*dVDSSprime_dVD)+ddeltaV_dVD)*d_tmp2_dV_g_b+((VDSSprime*d_dVDSSprime_dVD_dV_g_b+d_VDSSprime_dV_g_b*dVDSSprime_dVD)+d_ddeltaV_dVD_dV_g_b)*tmp2))+(((Vdsprime*(0.5-dVDSSprime_dVD))+ddeltaV_dVD)*d_tmp3_dV_g_b+((Vdsprime*(-d_dVDSSprime_dVD_dV_g_b)+d_Vdsprime_dV_g_b*(0.5-dVDSSprime_dVD))+d_ddeltaV_dVD_dV_g_b)*tmp3))+d_tmp1_dV_g_b*(((dVP_dVD-0.5)-(((VDSSprime*dVDSSprime_dVD)+ddeltaV_dVD)*tmp2))+(((Vdsprime*(0.5-dVDSSprime_dVD))+ddeltaV_dVD)*tmp3)));
dirprime_dVD = (tmp1*(((dVP_dVD-0.5)-(((VDSSprime*dVDSSprime_dVD)+ddeltaV_dVD)*tmp2))+(((Vdsprime*(0.5-dVDSSprime_dVD))+ddeltaV_dVD)*tmp3)));

d_dirprime_dVS_dV_s_b = (tmp1*((d_dVP_dVS_dV_s_b-(((VDSSprime*dVDSSprime_dVS)+ddeltaV_dVS)*d_tmp2_dV_s_b+((VDSSprime*d_dVDSSprime_dVS_dV_s_b+d_VDSSprime_dV_s_b*dVDSSprime_dVS)+d_ddeltaV_dVS_dV_s_b)*tmp2))+(((Vdsprime*((-0.5)-dVDSSprime_dVS))+ddeltaV_dVS)*d_tmp3_dV_s_b+((Vdsprime*(-d_dVDSSprime_dVS_dV_s_b)+d_Vdsprime_dV_s_b*((-0.5)-dVDSSprime_dVS))+d_ddeltaV_dVS_dV_s_b)*tmp3))+d_tmp1_dV_s_b*(((dVP_dVS-0.5)-(((VDSSprime*dVDSSprime_dVS)+ddeltaV_dVS)*tmp2))+(((Vdsprime*((-0.5)-dVDSSprime_dVS))+ddeltaV_dVS)*tmp3)));
d_dirprime_dVS_dV_d_b = (tmp1*((d_dVP_dVS_dV_d_b-(((VDSSprime*dVDSSprime_dVS)+ddeltaV_dVS)*d_tmp2_dV_d_b+((VDSSprime*d_dVDSSprime_dVS_dV_d_b+d_VDSSprime_dV_d_b*dVDSSprime_dVS)+d_ddeltaV_dVS_dV_d_b)*tmp2))+(((Vdsprime*((-0.5)-dVDSSprime_dVS))+ddeltaV_dVS)*d_tmp3_dV_d_b+((Vdsprime*(-d_dVDSSprime_dVS_dV_d_b)+d_Vdsprime_dV_d_b*((-0.5)-dVDSSprime_dVS))+d_ddeltaV_dVS_dV_d_b)*tmp3))+d_tmp1_dV_d_b*(((dVP_dVS-0.5)-(((VDSSprime*dVDSSprime_dVS)+ddeltaV_dVS)*tmp2))+(((Vdsprime*((-0.5)-dVDSSprime_dVS))+ddeltaV_dVS)*tmp3)));
d_dirprime_dVS_dV_g_b = (tmp1*((d_dVP_dVS_dV_g_b-(((VDSSprime*dVDSSprime_dVS)+ddeltaV_dVS)*d_tmp2_dV_g_b+((VDSSprime*d_dVDSSprime_dVS_dV_g_b+d_VDSSprime_dV_g_b*dVDSSprime_dVS)+d_ddeltaV_dVS_dV_g_b)*tmp2))+(((Vdsprime*((-0.5)-dVDSSprime_dVS))+ddeltaV_dVS)*d_tmp3_dV_g_b+((Vdsprime*(-d_dVDSSprime_dVS_dV_g_b)+d_Vdsprime_dV_g_b*((-0.5)-dVDSSprime_dVS))+d_ddeltaV_dVS_dV_g_b)*tmp3))+d_tmp1_dV_g_b*(((dVP_dVS-0.5)-(((VDSSprime*dVDSSprime_dVS)+ddeltaV_dVS)*tmp2))+(((Vdsprime*((-0.5)-dVDSSprime_dVS))+ddeltaV_dVS)*tmp3)));
dirprime_dVS = (tmp1*(((dVP_dVS-0.5)-(((VDSSprime*dVDSSprime_dVS)+ddeltaV_dVS)*tmp2))+(((Vdsprime*((-0.5)-dVDSSprime_dVS))+ddeltaV_dVS)*tmp3)));
dirprime_dVG = (tmp1*((dVP_dVG-(((VDSSprime*dVDSSprime_dVG)+ddeltaV_dVG)*tmp2))+(((Vdsprime*(-dVDSSprime_dVG))+ddeltaV_dVG)*tmp3)));

d_tmp1_dV_g_b = (-Lc_LAMBDA*(-d_Vip_dV_g_b)/((Lc_UCRIT+Vds)-Vip)/((Lc_UCRIT+Vds)-Vip));
d_tmp1_dV_d_b = (-Lc_LAMBDA*(d_Vds_dV_d_b-d_Vip_dV_d_b)/((Lc_UCRIT+Vds)-Vip)/((Lc_UCRIT+Vds)-Vip));
d_tmp1_dV_s_b = (-Lc_LAMBDA*(d_Vds_dV_s_b-d_Vip_dV_s_b)/((Lc_UCRIT+Vds)-Vip)/((Lc_UCRIT+Vds)-Vip));
tmp1 = (Lc_LAMBDA/((Lc_UCRIT+Vds)-Vip));

d_ddeltaL_dVD_dV_s_b = (tmp1*(-d_dVip_dVD_dV_s_b)+d_tmp1_dV_s_b*(0.5-dVip_dVD));
d_ddeltaL_dVD_dV_d_b = (tmp1*(-d_dVip_dVD_dV_d_b)+d_tmp1_dV_d_b*(0.5-dVip_dVD));
d_ddeltaL_dVD_dV_g_b = (tmp1*(-d_dVip_dVD_dV_g_b)+d_tmp1_dV_g_b*(0.5-dVip_dVD));
ddeltaL_dVD = (tmp1*(0.5-dVip_dVD));

d_ddeltaL_dVS_dV_s_b = (tmp1*(-d_dVip_dVS_dV_s_b)+d_tmp1_dV_s_b*((-0.5)-dVip_dVS));
d_ddeltaL_dVS_dV_d_b = (tmp1*(-d_dVip_dVS_dV_d_b)+d_tmp1_dV_d_b*((-0.5)-dVip_dVS));
d_ddeltaL_dVS_dV_g_b = (tmp1*(-d_dVip_dVS_dV_g_b)+d_tmp1_dV_g_b*((-0.5)-dVip_dVS));
ddeltaL_dVS = (tmp1*((-0.5)-dVip_dVS));
ddeltaL_dVG = ((-tmp1)*dVip_dVG);

d_tmp1_dV_g_b = (-d_sqrt_Lprime_Lmin_dV_g_b/sqrt_Lprime_Lmin/sqrt_Lprime_Lmin);
d_tmp1_dV_d_b = (-d_sqrt_Lprime_Lmin_dV_d_b/sqrt_Lprime_Lmin/sqrt_Lprime_Lmin);
d_tmp1_dV_s_b = (-d_sqrt_Lprime_Lmin_dV_s_b/sqrt_Lprime_Lmin/sqrt_Lprime_Lmin);
tmp1 = (1.0/sqrt_Lprime_Lmin);

d_dLeq_dVD_dV_s_b = (tmp1*((-d_ddeltaL_dVD_dV_s_b)+d_dVip_dVD_dV_s_b*inv_UCRIT)+d_tmp1_dV_s_b*((-ddeltaL_dVD)+((0.5+dVip_dVD)*inv_UCRIT)));
d_dLeq_dVD_dV_d_b = (tmp1*((-d_ddeltaL_dVD_dV_d_b)+d_dVip_dVD_dV_d_b*inv_UCRIT)+d_tmp1_dV_d_b*((-ddeltaL_dVD)+((0.5+dVip_dVD)*inv_UCRIT)));
d_dLeq_dVD_dV_g_b = (tmp1*((-d_ddeltaL_dVD_dV_g_b)+d_dVip_dVD_dV_g_b*inv_UCRIT)+d_tmp1_dV_g_b*((-ddeltaL_dVD)+((0.5+dVip_dVD)*inv_UCRIT)));
dLeq_dVD = (tmp1*((-ddeltaL_dVD)+((0.5+dVip_dVD)*inv_UCRIT)));

d_dLeq_dVS_dV_s_b = (tmp1*((-d_ddeltaL_dVS_dV_s_b)+d_dVip_dVS_dV_s_b*inv_UCRIT)+d_tmp1_dV_s_b*((-ddeltaL_dVS)+(((-0.5)+dVip_dVS)*inv_UCRIT)));
d_dLeq_dVS_dV_d_b = (tmp1*((-d_ddeltaL_dVS_dV_d_b)+d_dVip_dVS_dV_d_b*inv_UCRIT)+d_tmp1_dV_d_b*((-ddeltaL_dVS)+(((-0.5)+dVip_dVS)*inv_UCRIT)));
d_dLeq_dVS_dV_g_b = (tmp1*((-d_ddeltaL_dVS_dV_g_b)+d_dVip_dVS_dV_g_b*inv_UCRIT)+d_tmp1_dV_g_b*((-ddeltaL_dVS)+(((-0.5)+dVip_dVS)*inv_UCRIT)));
dLeq_dVS = (tmp1*((-ddeltaL_dVS)+(((-0.5)+dVip_dVS)*inv_UCRIT)));
dLeq_dVG = (tmp1*((-ddeltaL_dVG)+(dVip_dVG*inv_UCRIT)));

d_tmp1_dV_s_b = d_dir_dv_dV_s_b*inv_Vt;
d_tmp1_dV_d_b = d_dir_dv_dV_d_b*inv_Vt;
d_tmp1_dV_g_b = d_dir_dv_dV_g_b*inv_Vt;
tmp1 = (dir_dv*inv_Vt);

d_dir_dVD_dV_s_b = (tmp1*d_dVP_dVD_dV_s_b+d_tmp1_dV_s_b*(dVP_dVD-1.0));
d_dir_dVD_dV_d_b = (tmp1*d_dVP_dVD_dV_d_b+d_tmp1_dV_d_b*(dVP_dVD-1.0));
d_dir_dVD_dV_g_b = (tmp1*d_dVP_dVD_dV_g_b+d_tmp1_dV_g_b*(dVP_dVD-1.0));
dir_dVD = (tmp1*(dVP_dVD-1.0));

d_dir_dVS_dV_s_b = (tmp1*d_dVP_dVS_dV_s_b+d_tmp1_dV_s_b*dVP_dVS);
d_dir_dVS_dV_d_b = (tmp1*d_dVP_dVS_dV_d_b+d_tmp1_dV_d_b*dVP_dVS);
d_dir_dVS_dV_g_b = (tmp1*d_dVP_dVS_dV_g_b+d_tmp1_dV_g_b*dVP_dVS);
dir_dVS = (tmp1*dVP_dVS);
dir_dVG = (tmp1*dVP_dVG);

d_tmp1_dV_s_b = ((sif_sir_2*(-d_n_1_dV_s_b)*Vt*0.66666666-(((-(1.0+n_1))*Vt)*0.66666666)*d_sif_sir_2_dV_s_b)/sif_sir_2/sif_sir_2);
d_tmp1_dV_d_b = ((sif_sir_2*(-d_n_1_dV_d_b)*Vt*0.66666666-(((-(1.0+n_1))*Vt)*0.66666666)*d_sif_sir_2_dV_d_b)/sif_sir_2/sif_sir_2);
d_tmp1_dV_g_b = ((sif_sir_2*(-d_n_1_dV_g_b)*Vt*0.66666666-(((-(1.0+n_1))*Vt)*0.66666666)*d_sif_sir_2_dV_g_b)/sif_sir_2/sif_sir_2);
tmp1 = ((((-(1.0+n_1))*Vt)*0.66666666)/sif_sir_2);

d_tmp2_dV_s_b = (tmp1*(d_sif_dV_s_b+2.0*d_sir_dV_s_b)+d_tmp1_dV_s_b*(sif+(2.0*sir)));
d_tmp2_dV_d_b = (tmp1*(d_sif_dV_d_b+2.0*d_sir_dV_d_b)+d_tmp1_dV_d_b*(sif+(2.0*sir)));
d_tmp2_dV_g_b = (tmp1*(d_sif_dV_g_b+2.0*d_sir_dV_g_b)+d_tmp1_dV_g_b*(sif+(2.0*sir)));
tmp2 = (tmp1*(sif+(2.0*sir)));

d_tmp3_dV_s_b = (tmp1*(d_sir_dV_s_b+2.0*d_sif_dV_s_b)+d_tmp1_dV_s_b*(sir+(2.0*sif)));
d_tmp3_dV_d_b = (tmp1*(d_sir_dV_d_b+2.0*d_sif_dV_d_b)+d_tmp1_dV_d_b*(sir+(2.0*sif)));
d_tmp3_dV_g_b = (tmp1*(d_sir_dV_g_b+2.0*d_sif_dV_g_b)+d_tmp1_dV_g_b*(sir+(2.0*sif)));
tmp3 = (tmp1*(sir+(2.0*sif)));

d_tmp1_dV_s_b = (((((2.0+n_1)+n_1)*VP_PHI_eps)*((-n_1)*d_qi_dV_s_b+(-d_n_1_dV_s_b)*qi)-((-n_1)*qi)*(((2.0+n_1)+n_1)*d_VP_PHI_eps_dV_s_b+(d_n_1_dV_s_b+d_n_1_dV_s_b)*VP_PHI_eps))/(((2.0+n_1)+n_1)*VP_PHI_eps)/(((2.0+n_1)+n_1)*VP_PHI_eps));
d_tmp1_dV_d_b = (((((2.0+n_1)+n_1)*VP_PHI_eps)*((-n_1)*d_qi_dV_d_b+(-d_n_1_dV_d_b)*qi)-((-n_1)*qi)*(((2.0+n_1)+n_1)*d_VP_PHI_eps_dV_d_b+(d_n_1_dV_d_b+d_n_1_dV_d_b)*VP_PHI_eps))/(((2.0+n_1)+n_1)*VP_PHI_eps)/(((2.0+n_1)+n_1)*VP_PHI_eps));
d_tmp1_dV_g_b = (((((2.0+n_1)+n_1)*VP_PHI_eps)*((-n_1)*d_qi_dV_g_b+(-d_n_1_dV_g_b)*qi)-((-n_1)*qi)*(((2.0+n_1)+n_1)*d_VP_PHI_eps_dV_g_b+(d_n_1_dV_g_b+d_n_1_dV_g_b)*VP_PHI_eps))/(((2.0+n_1)+n_1)*VP_PHI_eps)/(((2.0+n_1)+n_1)*VP_PHI_eps));
tmp1 = (((-n_1)*qi)/(((2.0+n_1)+n_1)*VP_PHI_eps));

d_dQI_dVD_dV_s_b = (((tmp1*d_dVP_dVD_dV_s_b+d_tmp1_dV_s_b*dVP_dVD)+(tmp2*d_dif_dVD_dV_s_b+d_tmp2_dV_s_b*dif_dVD))+(tmp3*d_dir_dVD_dV_s_b+d_tmp3_dV_s_b*dir_dVD));
d_dQI_dVD_dV_d_b = (((tmp1*d_dVP_dVD_dV_d_b+d_tmp1_dV_d_b*dVP_dVD)+(tmp2*d_dif_dVD_dV_d_b+d_tmp2_dV_d_b*dif_dVD))+(tmp3*d_dir_dVD_dV_d_b+d_tmp3_dV_d_b*dir_dVD));
d_dQI_dVD_dV_g_b = (((tmp1*d_dVP_dVD_dV_g_b+d_tmp1_dV_g_b*dVP_dVD)+(tmp2*d_dif_dVD_dV_g_b+d_tmp2_dV_g_b*dif_dVD))+(tmp3*d_dir_dVD_dV_g_b+d_tmp3_dV_g_b*dir_dVD));
dQI_dVD = (((tmp1*dVP_dVD)+(tmp2*dif_dVD))+(tmp3*dir_dVD));

d_dQI_dVS_dV_s_b = (((tmp1*d_dVP_dVS_dV_s_b+d_tmp1_dV_s_b*dVP_dVS)+(tmp2*d_dif_dVS_dV_s_b+d_tmp2_dV_s_b*dif_dVS))+(tmp3*d_dir_dVS_dV_s_b+d_tmp3_dV_s_b*dir_dVS));
d_dQI_dVS_dV_d_b = (((tmp1*d_dVP_dVS_dV_d_b+d_tmp1_dV_d_b*dVP_dVS)+(tmp2*d_dif_dVS_dV_d_b+d_tmp2_dV_d_b*dif_dVS))+(tmp3*d_dir_dVS_dV_d_b+d_tmp3_dV_d_b*dir_dVS));
d_dQI_dVS_dV_g_b = (((tmp1*d_dVP_dVS_dV_g_b+d_tmp1_dV_g_b*dVP_dVS)+(tmp2*d_dif_dVS_dV_g_b+d_tmp2_dV_g_b*dif_dVS))+(tmp3*d_dir_dVS_dV_g_b+d_tmp3_dV_g_b*dir_dVS));
dQI_dVS = (((tmp1*dVP_dVS)+(tmp2*dif_dVS))+(tmp3*dir_dVS));
dQI_dVG = (((tmp1*dVP_dVG)+(tmp2*dif_dVG))+(tmp3*dir_dVG));

d_tmp1_dV_s_b = (d_n_1_dV_s_b-((((2.0*(1.0+n_1))*VP_PHI_eps)*d_qi_dV_s_b-qi*((2.0*(1.0+n_1))*d_VP_PHI_eps_dV_s_b+2.0*d_n_1_dV_s_b*VP_PHI_eps))/((2.0*(1.0+n_1))*VP_PHI_eps)/((2.0*(1.0+n_1))*VP_PHI_eps)));
d_tmp1_dV_d_b = (d_n_1_dV_d_b-((((2.0*(1.0+n_1))*VP_PHI_eps)*d_qi_dV_d_b-qi*((2.0*(1.0+n_1))*d_VP_PHI_eps_dV_d_b+2.0*d_n_1_dV_d_b*VP_PHI_eps))/((2.0*(1.0+n_1))*VP_PHI_eps)/((2.0*(1.0+n_1))*VP_PHI_eps)));
d_tmp1_dV_g_b = (d_n_1_dV_g_b-((((2.0*(1.0+n_1))*VP_PHI_eps)*d_qi_dV_g_b-qi*((2.0*(1.0+n_1))*d_VP_PHI_eps_dV_g_b+2.0*d_n_1_dV_g_b*VP_PHI_eps))/((2.0*(1.0+n_1))*VP_PHI_eps)/((2.0*(1.0+n_1))*VP_PHI_eps)));
tmp1 = ((1.0+n_1)-(qi/((2.0*(1.0+n_1))*VP_PHI_eps)));

d_dQB_dVD_dV_s_b = ((-n_1_n)*((tmp1*d_dVP_dVD_dV_s_b+d_tmp1_dV_s_b*dVP_dVD)+d_dQI_dVD_dV_s_b)+(-d_n_1_n_dV_s_b)*((tmp1*dVP_dVD)+dQI_dVD));
d_dQB_dVD_dV_d_b = ((-n_1_n)*((tmp1*d_dVP_dVD_dV_d_b+d_tmp1_dV_d_b*dVP_dVD)+d_dQI_dVD_dV_d_b)+(-d_n_1_n_dV_d_b)*((tmp1*dVP_dVD)+dQI_dVD));
d_dQB_dVD_dV_g_b = ((-n_1_n)*((tmp1*d_dVP_dVD_dV_g_b+d_tmp1_dV_g_b*dVP_dVD)+d_dQI_dVD_dV_g_b)+(-d_n_1_n_dV_g_b)*((tmp1*dVP_dVD)+dQI_dVD));
dQB_dVD = ((-n_1_n)*((tmp1*dVP_dVD)+dQI_dVD));

d_dQB_dVS_dV_s_b = ((-n_1_n)*((tmp1*d_dVP_dVS_dV_s_b+d_tmp1_dV_s_b*dVP_dVS)+d_dQI_dVS_dV_s_b)+(-d_n_1_n_dV_s_b)*((tmp1*dVP_dVS)+dQI_dVS));
d_dQB_dVS_dV_d_b = ((-n_1_n)*((tmp1*d_dVP_dVS_dV_d_b+d_tmp1_dV_d_b*dVP_dVS)+d_dQI_dVS_dV_d_b)+(-d_n_1_n_dV_d_b)*((tmp1*dVP_dVS)+dQI_dVS));
d_dQB_dVS_dV_g_b = ((-n_1_n)*((tmp1*d_dVP_dVS_dV_g_b+d_tmp1_dV_g_b*dVP_dVS)+d_dQI_dVS_dV_g_b)+(-d_n_1_n_dV_g_b)*((tmp1*dVP_dVS)+dQI_dVS));
dQB_dVS = ((-n_1_n)*((tmp1*dVP_dVS)+dQI_dVS));
dQB_dVG = ((-n_1_n)*((tmp1*dVP_dVG)+dQI_dVG));
if (((model_.E0)==0.0))
{

d_tmp1_dV_s_b = (((THETA_VP_1*sqrt_VP_Vt)*(model_.THETA)*d_VPprime_dV_s_b-((model_.THETA)*VPprime)*(THETA_VP_1*d_sqrt_VP_Vt_dV_s_b+d_THETA_VP_1_dV_s_b*sqrt_VP_Vt))/(THETA_VP_1*sqrt_VP_Vt)/(THETA_VP_1*sqrt_VP_Vt));
d_tmp1_dV_d_b = (((THETA_VP_1*sqrt_VP_Vt)*(model_.THETA)*d_VPprime_dV_d_b-((model_.THETA)*VPprime)*(THETA_VP_1*d_sqrt_VP_Vt_dV_d_b+d_THETA_VP_1_dV_d_b*sqrt_VP_Vt))/(THETA_VP_1*sqrt_VP_Vt)/(THETA_VP_1*sqrt_VP_Vt));
d_tmp1_dV_g_b = (((THETA_VP_1*sqrt_VP_Vt)*(model_.THETA)*d_VPprime_dV_g_b-((model_.THETA)*VPprime)*(THETA_VP_1*d_sqrt_VP_Vt_dV_g_b+d_THETA_VP_1_dV_g_b*sqrt_VP_Vt))/(THETA_VP_1*sqrt_VP_Vt)/(THETA_VP_1*sqrt_VP_Vt));
tmp1 = (((model_.THETA)*VPprime)/(THETA_VP_1*sqrt_VP_Vt));

d_dVPprime_dVD_dV_s_b = (tmp1*d_dVP_dVD_dV_s_b+d_tmp1_dV_s_b*dVP_dVD);
d_dVPprime_dVD_dV_d_b = (tmp1*d_dVP_dVD_dV_d_b+d_tmp1_dV_d_b*dVP_dVD);
d_dVPprime_dVD_dV_g_b = (tmp1*d_dVP_dVD_dV_g_b+d_tmp1_dV_g_b*dVP_dVD);
dVPprime_dVD = (tmp1*dVP_dVD);

d_dVPprime_dVS_dV_s_b = (tmp1*d_dVP_dVS_dV_s_b+d_tmp1_dV_s_b*dVP_dVS);
d_dVPprime_dVS_dV_d_b = (tmp1*d_dVP_dVS_dV_d_b+d_tmp1_dV_d_b*dVP_dVS);
d_dVPprime_dVS_dV_g_b = (tmp1*d_dVP_dVS_dV_g_b+d_tmp1_dV_g_b*dVP_dVS);
dVPprime_dVS = (tmp1*dVP_dVS);
dVPprime_dVG = (tmp1*dVP_dVG);

d_dbeta_dVD_dV_s_b = ((-d_dLeq_dVD_dV_s_b)-d_dVPprime_dVD_dV_s_b);
d_dbeta_dVD_dV_d_b = ((-d_dLeq_dVD_dV_d_b)-d_dVPprime_dVD_dV_d_b);
d_dbeta_dVD_dV_g_b = ((-d_dLeq_dVD_dV_g_b)-d_dVPprime_dVD_dV_g_b);
dbeta_dVD = ((-dLeq_dVD)-dVPprime_dVD);

d_dbeta_dVS_dV_s_b = ((-d_dLeq_dVS_dV_s_b)-d_dVPprime_dVS_dV_s_b);
d_dbeta_dVS_dV_d_b = ((-d_dLeq_dVS_dV_d_b)-d_dVPprime_dVS_dV_d_b);
d_dbeta_dVS_dV_g_b = ((-d_dLeq_dVS_dV_g_b)-d_dVPprime_dVS_dV_g_b);
dbeta_dVS = ((-dLeq_dVS)-dVPprime_dVS);
dbeta_dVG = ((-dLeq_dVG)-dVPprime_dVG);
}
else
{

d_tmp1_dV_s_b = (-T0*d_E0_Q_1_dV_s_b/E0_Q_1/E0_Q_1);
d_tmp1_dV_d_b = (-T0*d_E0_Q_1_dV_d_b/E0_Q_1/E0_Q_1);
d_tmp1_dV_g_b = (-T0*d_E0_Q_1_dV_g_b/E0_Q_1/E0_Q_1);
tmp1 = (T0/E0_Q_1);

d_dbeta_dVD_dV_s_b = ((-d_dLeq_dVD_dV_s_b)+(tmp1*(d_dQB_dVD_dV_s_b+eta_qi*d_dQI_dVD_dV_s_b)+d_tmp1_dV_s_b*(dQB_dVD+(eta_qi*dQI_dVD))));
d_dbeta_dVD_dV_d_b = ((-d_dLeq_dVD_dV_d_b)+(tmp1*(d_dQB_dVD_dV_d_b+eta_qi*d_dQI_dVD_dV_d_b)+d_tmp1_dV_d_b*(dQB_dVD+(eta_qi*dQI_dVD))));
d_dbeta_dVD_dV_g_b = ((-d_dLeq_dVD_dV_g_b)+(tmp1*(d_dQB_dVD_dV_g_b+eta_qi*d_dQI_dVD_dV_g_b)+d_tmp1_dV_g_b*(dQB_dVD+(eta_qi*dQI_dVD))));
dbeta_dVD = ((-dLeq_dVD)+(tmp1*(dQB_dVD+(eta_qi*dQI_dVD))));

d_dbeta_dVS_dV_s_b = ((-d_dLeq_dVS_dV_s_b)+(tmp1*(d_dQB_dVS_dV_s_b+eta_qi*d_dQI_dVS_dV_s_b)+d_tmp1_dV_s_b*(dQB_dVS+(eta_qi*dQI_dVS))));
d_dbeta_dVS_dV_d_b = ((-d_dLeq_dVS_dV_d_b)+(tmp1*(d_dQB_dVS_dV_d_b+eta_qi*d_dQI_dVS_dV_d_b)+d_tmp1_dV_d_b*(dQB_dVS+(eta_qi*dQI_dVS))));
d_dbeta_dVS_dV_g_b = ((-d_dLeq_dVS_dV_g_b)+(tmp1*(d_dQB_dVS_dV_g_b+eta_qi*d_dQI_dVS_dV_g_b)+d_tmp1_dV_g_b*(dQB_dVS+(eta_qi*dQI_dVS))));
dbeta_dVS = ((-dLeq_dVS)+(tmp1*(dQB_dVS+(eta_qi*dQI_dVS))));
dbeta_dVG = ((-dLeq_dVG)+(tmp1*(dQB_dVG+(eta_qi*dQI_dVG))));
}

d_tmp1_dV_s_b = (-(-GAMMA_S)*(((4.0*n)*sqrt_PHI_VP)*d_VP_dV_s_b+((4.0*n)*d_sqrt_PHI_VP_dV_s_b+4.0*d_n_dV_s_b*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4))/(((4.0*n)*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4))/(((4.0*n)*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4)));
d_tmp1_dV_d_b = (-(-GAMMA_S)*(((4.0*n)*sqrt_PHI_VP)*d_VP_dV_d_b+((4.0*n)*d_sqrt_PHI_VP_dV_d_b+4.0*d_n_dV_d_b*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4))/(((4.0*n)*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4))/(((4.0*n)*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4)));
d_tmp1_dV_g_b = (-(-GAMMA_S)*(((4.0*n)*sqrt_PHI_VP)*d_VP_dV_g_b+((4.0*n)*d_sqrt_PHI_VP_dV_g_b+4.0*d_n_dV_g_b*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4))/(((4.0*n)*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4))/(((4.0*n)*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4)));
tmp1 = ((-GAMMA_S)/(((4.0*n)*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4)));

d_dn_dVD_dV_s_b = (tmp1*d_dVP_dVD_dV_s_b+d_tmp1_dV_s_b*dVP_dVD);
d_dn_dVD_dV_d_b = (tmp1*d_dVP_dVD_dV_d_b+d_tmp1_dV_d_b*dVP_dVD);
d_dn_dVD_dV_g_b = (tmp1*d_dVP_dVD_dV_g_b+d_tmp1_dV_g_b*dVP_dVD);
dn_dVD = (tmp1*dVP_dVD);

d_dn_dVS_dV_s_b = (tmp1*d_dVP_dVS_dV_s_b+d_tmp1_dV_s_b*dVP_dVS);
d_dn_dVS_dV_d_b = (tmp1*d_dVP_dVS_dV_d_b+d_tmp1_dV_d_b*dVP_dVS);
d_dn_dVS_dV_g_b = (tmp1*d_dVP_dVS_dV_g_b+d_tmp1_dV_g_b*dVP_dVS);
dn_dVS = (tmp1*dVP_dVS);
dn_dVG = (tmp1*dVP_dVG);

d_gds_dV_s_b = (Ispec*((((dn_dVD+dbeta_dVD)*d_if_ir_dV_s_b+(d_dn_dVD_dV_s_b+d_dbeta_dVD_dV_s_b)*if_ir)+d_dif_dVD_dV_s_b)-d_dirprime_dVD_dV_s_b)+d_Ispec_dV_s_b*((((dn_dVD+dbeta_dVD)*if_ir)+dif_dVD)-dirprime_dVD));
d_gds_dV_d_b = (Ispec*((((dn_dVD+dbeta_dVD)*d_if_ir_dV_d_b+(d_dn_dVD_dV_d_b+d_dbeta_dVD_dV_d_b)*if_ir)+d_dif_dVD_dV_d_b)-d_dirprime_dVD_dV_d_b)+d_Ispec_dV_d_b*((((dn_dVD+dbeta_dVD)*if_ir)+dif_dVD)-dirprime_dVD));
d_gds_dV_g_b = (Ispec*((((dn_dVD+dbeta_dVD)*d_if_ir_dV_g_b+(d_dn_dVD_dV_g_b+d_dbeta_dVD_dV_g_b)*if_ir)+d_dif_dVD_dV_g_b)-d_dirprime_dVD_dV_g_b)+d_Ispec_dV_g_b*((((dn_dVD+dbeta_dVD)*if_ir)+dif_dVD)-dirprime_dVD));
gds = (Ispec*((((dn_dVD+dbeta_dVD)*if_ir)+dif_dVD)-dirprime_dVD));

d_gms_dV_s_b = ((-Ispec)*((((dn_dVS+dbeta_dVS)*d_if_ir_dV_s_b+(d_dn_dVS_dV_s_b+d_dbeta_dVS_dV_s_b)*if_ir)+d_dif_dVS_dV_s_b)-d_dirprime_dVS_dV_s_b)+(-d_Ispec_dV_s_b)*((((dn_dVS+dbeta_dVS)*if_ir)+dif_dVS)-dirprime_dVS));
d_gms_dV_d_b = ((-Ispec)*((((dn_dVS+dbeta_dVS)*d_if_ir_dV_d_b+(d_dn_dVS_dV_d_b+d_dbeta_dVS_dV_d_b)*if_ir)+d_dif_dVS_dV_d_b)-d_dirprime_dVS_dV_d_b)+(-d_Ispec_dV_d_b)*((((dn_dVS+dbeta_dVS)*if_ir)+dif_dVS)-dirprime_dVS));
d_gms_dV_g_b = ((-Ispec)*((((dn_dVS+dbeta_dVS)*d_if_ir_dV_g_b+(d_dn_dVS_dV_g_b+d_dbeta_dVS_dV_g_b)*if_ir)+d_dif_dVS_dV_g_b)-d_dirprime_dVS_dV_g_b)+(-d_Ispec_dV_g_b)*((((dn_dVS+dbeta_dVS)*if_ir)+dif_dVS)-dirprime_dVS));
gms = ((-Ispec)*((((dn_dVS+dbeta_dVS)*if_ir)+dif_dVS)-dirprime_dVS));
gm = (Ispec*((((dn_dVG+dbeta_dVG)*if_ir)+dif_dVG)-dirprime_dVG));
gmbs = ((gms-gm)-gds);
RSeff = (((model_.RSH)*(model_.HDIF))/(Weff-(model_.DW)));
RDeff = (((model_.RSH)*(model_.HDIF))/(Weff-(model_.DW)));

d_tmp1_dV_s_b = (-(d_gms_dV_s_b*RSeff+d_gds_dV_s_b*RDeff)/((1.0+(gms*RSeff))+(gds*RDeff))/((1.0+(gms*RSeff))+(gds*RDeff)));
d_tmp1_dV_d_b = (-(d_gms_dV_d_b*RSeff+d_gds_dV_d_b*RDeff)/((1.0+(gms*RSeff))+(gds*RDeff))/((1.0+(gms*RSeff))+(gds*RDeff)));
d_tmp1_dV_g_b = (-(d_gms_dV_g_b*RSeff+d_gds_dV_g_b*RDeff)/((1.0+(gms*RSeff))+(gds*RDeff))/((1.0+(gms*RSeff))+(gds*RDeff)));
tmp1 = (1.0/((1.0+(gms*RSeff))+(gds*RDeff)));

d_Id_dV_s_b = (Id*d_tmp1_dV_s_b+d_Id_dV_s_b*tmp1);
d_Id_dV_d_b = (Id*d_tmp1_dV_d_b+d_Id_dV_d_b*tmp1);
d_Id_dV_g_b = (Id*d_tmp1_dV_g_b+d_Id_dV_g_b*tmp1);
Id = (Id*tmp1);

d_Vib_dV_g_b = (-IBN_2*d_VDSS_dV_g_b);
d_Vib_dV_d_b = ((d_VD_dV_d_b-d_VS_dV_d_b)-IBN_2*d_VDSS_dV_d_b);
d_Vib_dV_s_b = ((d_VD_dV_s_b-d_VS_dV_s_b)-IBN_2*d_VDSS_dV_s_b);
Vib = ((VD-VS)-(IBN_2*VDSS));
if (((Vib>0.0)&&(IBA_IBB>0.0)))
{

d_inv_Vib_dV_g_b = (-d_Vib_dV_g_b/Vib/Vib);
d_inv_Vib_dV_d_b = (-d_Vib_dV_d_b/Vib/Vib);
d_inv_Vib_dV_s_b = (-d_Vib_dV_s_b/Vib/Vib);
inv_Vib = (1.0/Vib);

d_Lc_IBB_Vib_dV_g_b = (-Lc_IBB)*d_inv_Vib_dV_g_b;
d_Lc_IBB_Vib_dV_d_b = (-Lc_IBB)*d_inv_Vib_dV_d_b;
d_Lc_IBB_Vib_dV_s_b = (-Lc_IBB)*d_inv_Vib_dV_s_b;
Lc_IBB_Vib = ((-Lc_IBB)*inv_Vib);
if ((Lc_IBB_Vib<(-35.0)))
{

d_Lc_IBB_Vib_dV_s_b = d_Lc_IBB_Vib_dV_d_b = d_Lc_IBB_Vib_dV_g_b =  0.0;
Lc_IBB_Vib = (-35.0);
}
{
double value_exp_0 = exp(Lc_IBB_Vib);
double  deriv_exp_0_d0 = value_exp_0;

d_exp_ib_dV_g_b = (deriv_exp_0_d0*(d_Lc_IBB_Vib_dV_g_b));
d_exp_ib_dV_d_b = (deriv_exp_0_d0*(d_Lc_IBB_Vib_dV_d_b));
d_exp_ib_dV_s_b = (deriv_exp_0_d0*(d_Lc_IBB_Vib_dV_s_b));
exp_ib = value_exp_0;
}

d_isub_dV_g_b = ((IBA_IBB*Vib)*d_exp_ib_dV_g_b+IBA_IBB*d_Vib_dV_g_b*exp_ib);
d_isub_dV_d_b = ((IBA_IBB*Vib)*d_exp_ib_dV_d_b+IBA_IBB*d_Vib_dV_d_b*exp_ib);
d_isub_dV_s_b = ((IBA_IBB*Vib)*d_exp_ib_dV_s_b+IBA_IBB*d_Vib_dV_s_b*exp_ib);
isub = ((IBA_IBB*Vib)*exp_ib);

d_Isub_dV_g_b = (isub*d_Id_dV_g_b+d_isub_dV_g_b*Id);
d_Isub_dV_d_b = (isub*d_Id_dV_d_b+d_isub_dV_d_b*Id);
d_Isub_dV_s_b = (isub*d_Id_dV_s_b+d_isub_dV_s_b*Id);
Isub = (isub*Id);
dIsub_factor = ((Isub*inv_Vib)*(1.0-Lc_IBB_Vib));
}
else
{

d_Lc_IBB_Vib_dV_s_b = d_Lc_IBB_Vib_dV_d_b = d_Lc_IBB_Vib_dV_g_b =  0.0;
Lc_IBB_Vib = 0.0;

d_Isub_dV_s_b = d_Isub_dV_d_b = d_Isub_dV_g_b =  0.0;
Isub = 0.0;
}
Ibd = (Ibd-Isub);
WLCox = ((Weff*Leff)*(model_.COX));

d_sif3_dV_s_b = (sif*d_sif2_dV_s_b+d_sif_dV_s_b*sif2);
d_sif3_dV_d_b = (sif*d_sif2_dV_d_b+d_sif_dV_d_b*sif2);
d_sif3_dV_g_b = (sif*d_sif2_dV_g_b+d_sif_dV_g_b*sif2);
sif3 = (sif*sif2);

d_sir3_dV_s_b = (sir*d_sir2_dV_s_b+d_sir_dV_s_b*sir2);
d_sir3_dV_d_b = (sir*d_sir2_dV_d_b+d_sir_dV_d_b*sir2);
d_sir3_dV_g_b = (sir*d_sir2_dV_g_b+d_sir_dV_g_b*sir2);
sir3 = (sir*sir2);
{
double value_sqrt_0 = sqrt((PHI_T+(0.5*VP)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);

d_tmp1_dV_s_b = (deriv_sqrt_0_d0*(0.5*d_VP_dV_s_b));
d_tmp1_dV_d_b = (deriv_sqrt_0_d0*(0.5*d_VP_dV_d_b));
d_tmp1_dV_g_b = (deriv_sqrt_0_d0*(0.5*d_VP_dV_g_b));
tmp1 = value_sqrt_0;
}

d_sqrt_PHI_VP2_2_dV_s_b = (d_tmp1_dV_s_b+d_tmp1_dV_s_b);
d_sqrt_PHI_VP2_2_dV_d_b = (d_tmp1_dV_d_b+d_tmp1_dV_d_b);
d_sqrt_PHI_VP2_2_dV_g_b = (d_tmp1_dV_g_b+d_tmp1_dV_g_b);
sqrt_PHI_VP2_2 = (tmp1+tmp1);

d_n_Vt_COX_dV_g_b = ((sqrt_PHI_VP2_2*d_GAMMAprime_dV_g_b-GAMMAprime*d_sqrt_PHI_VP2_2_dV_g_b)/sqrt_PHI_VP2_2/sqrt_PHI_VP2_2)*Vt*WLCox;
d_n_Vt_COX_dV_s_b = ((sqrt_PHI_VP2_2*d_GAMMAprime_dV_s_b-GAMMAprime*d_sqrt_PHI_VP2_2_dV_s_b)/sqrt_PHI_VP2_2/sqrt_PHI_VP2_2)*Vt*WLCox;
d_n_Vt_COX_dV_d_b = ((sqrt_PHI_VP2_2*d_GAMMAprime_dV_d_b-GAMMAprime*d_sqrt_PHI_VP2_2_dV_d_b)/sqrt_PHI_VP2_2/sqrt_PHI_VP2_2)*Vt*WLCox;
n_Vt_COX = (((1.0+(GAMMAprime/sqrt_PHI_VP2_2))*Vt)*WLCox);

d_QD_dV_g_b = ((-n_Vt_COX)*((sif_sir_2*0.266666666*(((3.0*d_sir3_dV_g_b+((6.0*sir2)*d_sif_dV_g_b+6.0*d_sir2_dV_g_b*sif))+((4.0*sir)*d_sif2_dV_g_b+4.0*d_sir_dV_g_b*sif2))+2.0*d_sif3_dV_g_b)-(0.266666666*((((3.0*sir3)+((6.0*sir2)*sif))+((4.0*sir)*sif2))+(2.0*sif3)))*d_sif_sir_2_dV_g_b)/sif_sir_2/sif_sir_2)+(-d_n_Vt_COX_dV_g_b)*(((0.266666666*((((3.0*sir3)+((6.0*sir2)*sif))+((4.0*sir)*sif2))+(2.0*sif3)))/sif_sir_2)-0.5));
d_QD_dV_s_b = ((-n_Vt_COX)*((sif_sir_2*0.266666666*(((3.0*d_sir3_dV_s_b+((6.0*sir2)*d_sif_dV_s_b+6.0*d_sir2_dV_s_b*sif))+((4.0*sir)*d_sif2_dV_s_b+4.0*d_sir_dV_s_b*sif2))+2.0*d_sif3_dV_s_b)-(0.266666666*((((3.0*sir3)+((6.0*sir2)*sif))+((4.0*sir)*sif2))+(2.0*sif3)))*d_sif_sir_2_dV_s_b)/sif_sir_2/sif_sir_2)+(-d_n_Vt_COX_dV_s_b)*(((0.266666666*((((3.0*sir3)+((6.0*sir2)*sif))+((4.0*sir)*sif2))+(2.0*sif3)))/sif_sir_2)-0.5));
d_QD_dV_d_b = ((-n_Vt_COX)*((sif_sir_2*0.266666666*(((3.0*d_sir3_dV_d_b+((6.0*sir2)*d_sif_dV_d_b+6.0*d_sir2_dV_d_b*sif))+((4.0*sir)*d_sif2_dV_d_b+4.0*d_sir_dV_d_b*sif2))+2.0*d_sif3_dV_d_b)-(0.266666666*((((3.0*sir3)+((6.0*sir2)*sif))+((4.0*sir)*sif2))+(2.0*sif3)))*d_sif_sir_2_dV_d_b)/sif_sir_2/sif_sir_2)+(-d_n_Vt_COX_dV_d_b)*(((0.266666666*((((3.0*sir3)+((6.0*sir2)*sif))+((4.0*sir)*sif2))+(2.0*sif3)))/sif_sir_2)-0.5));
QD = ((-n_Vt_COX)*(((0.266666666*((((3.0*sir3)+((6.0*sir2)*sif))+((4.0*sir)*sif2))+(2.0*sif3)))/sif_sir_2)-0.5));

d_QS_dV_g_b = ((-n_Vt_COX)*((sif_sir_2*0.266666666*(((3.0*d_sif3_dV_g_b+((6.0*sif2)*d_sir_dV_g_b+6.0*d_sif2_dV_g_b*sir))+((4.0*sif)*d_sir2_dV_g_b+4.0*d_sif_dV_g_b*sir2))+2.0*d_sir3_dV_g_b)-(0.266666666*((((3.0*sif3)+((6.0*sif2)*sir))+((4.0*sif)*sir2))+(2.0*sir3)))*d_sif_sir_2_dV_g_b)/sif_sir_2/sif_sir_2)+(-d_n_Vt_COX_dV_g_b)*(((0.266666666*((((3.0*sif3)+((6.0*sif2)*sir))+((4.0*sif)*sir2))+(2.0*sir3)))/sif_sir_2)-0.5));
d_QS_dV_s_b = ((-n_Vt_COX)*((sif_sir_2*0.266666666*(((3.0*d_sif3_dV_s_b+((6.0*sif2)*d_sir_dV_s_b+6.0*d_sif2_dV_s_b*sir))+((4.0*sif)*d_sir2_dV_s_b+4.0*d_sif_dV_s_b*sir2))+2.0*d_sir3_dV_s_b)-(0.266666666*((((3.0*sif3)+((6.0*sif2)*sir))+((4.0*sif)*sir2))+(2.0*sir3)))*d_sif_sir_2_dV_s_b)/sif_sir_2/sif_sir_2)+(-d_n_Vt_COX_dV_s_b)*(((0.266666666*((((3.0*sif3)+((6.0*sif2)*sir))+((4.0*sif)*sir2))+(2.0*sir3)))/sif_sir_2)-0.5));
d_QS_dV_d_b = ((-n_Vt_COX)*((sif_sir_2*0.266666666*(((3.0*d_sif3_dV_d_b+((6.0*sif2)*d_sir_dV_d_b+6.0*d_sif2_dV_d_b*sir))+((4.0*sif)*d_sir2_dV_d_b+4.0*d_sif_dV_d_b*sir2))+2.0*d_sir3_dV_d_b)-(0.266666666*((((3.0*sif3)+((6.0*sif2)*sir))+((4.0*sif)*sir2))+(2.0*sir3)))*d_sif_sir_2_dV_d_b)/sif_sir_2/sif_sir_2)+(-d_n_Vt_COX_dV_d_b)*(((0.266666666*((((3.0*sif3)+((6.0*sif2)*sir))+((4.0*sif)*sir2))+(2.0*sir3)))/sif_sir_2)-0.5));
QS = ((-n_Vt_COX)*(((0.266666666*((((3.0*sif3)+((6.0*sif2)*sir))+((4.0*sif)*sir2))+(2.0*sir3)))/sif_sir_2)-0.5));

d_QI_dV_g_b = (d_QS_dV_g_b+d_QD_dV_g_b);
d_QI_dV_s_b = (d_QS_dV_s_b+d_QD_dV_s_b);
d_QI_dV_d_b = (d_QS_dV_d_b+d_QD_dV_d_b);
QI = (QS+QD);

d_QB_dV_g_b = (WLCox*(((((-0.5)*GAMMAprime)*d_sqrt_PHI_VP_2_dV_g_b+(-0.5)*d_GAMMAprime_dV_g_b*sqrt_PHI_VP_2)+d_VGprime_dV_g_b)-d_VGstar_dV_g_b)-(((GAMMAprime+sqrt_PHI_VP2_2)*(QI*d_GAMMAprime_dV_g_b+d_QI_dV_g_b*GAMMAprime)-(QI*GAMMAprime)*(d_GAMMAprime_dV_g_b+d_sqrt_PHI_VP2_2_dV_g_b))/(GAMMAprime+sqrt_PHI_VP2_2)/(GAMMAprime+sqrt_PHI_VP2_2)));
d_QB_dV_s_b = (WLCox*(((-0.5)*GAMMAprime)*d_sqrt_PHI_VP_2_dV_s_b+(-0.5)*d_GAMMAprime_dV_s_b*sqrt_PHI_VP_2)-(((GAMMAprime+sqrt_PHI_VP2_2)*(QI*d_GAMMAprime_dV_s_b+d_QI_dV_s_b*GAMMAprime)-(QI*GAMMAprime)*(d_GAMMAprime_dV_s_b+d_sqrt_PHI_VP2_2_dV_s_b))/(GAMMAprime+sqrt_PHI_VP2_2)/(GAMMAprime+sqrt_PHI_VP2_2)));
d_QB_dV_d_b = (WLCox*(((-0.5)*GAMMAprime)*d_sqrt_PHI_VP_2_dV_d_b+(-0.5)*d_GAMMAprime_dV_d_b*sqrt_PHI_VP_2)-(((GAMMAprime+sqrt_PHI_VP2_2)*(QI*d_GAMMAprime_dV_d_b+d_QI_dV_d_b*GAMMAprime)-(QI*GAMMAprime)*(d_GAMMAprime_dV_d_b+d_sqrt_PHI_VP2_2_dV_d_b))/(GAMMAprime+sqrt_PHI_VP2_2)/(GAMMAprime+sqrt_PHI_VP2_2)));
QB = ((WLCox*(((((-0.5)*GAMMAprime)*sqrt_PHI_VP_2)+VGprime)-VGstar))-((QI*GAMMAprime)/(GAMMAprime+sqrt_PHI_VP2_2)));

d_QG_dV_g_b = ((-d_QI_dV_g_b)-d_QB_dV_g_b);
d_QG_dV_s_b = ((-d_QI_dV_s_b)-d_QB_dV_s_b);
d_QG_dV_d_b = ((-d_QI_dV_d_b)-d_QB_dV_d_b);
QG = ((-QI)-QB);
// I(d,s) <+ (((TYPE*Mode)*Id))
staticContributions[admsNodeID_d] += (((model_.TYPE)*Mode)*Id);
d_staticContributions[admsNodeID_d][admsProbeID_V_s_b] += ((model_.TYPE)*Mode)*d_Id_dV_s_b;
d_staticContributions[admsNodeID_d][admsProbeID_V_d_b] += ((model_.TYPE)*Mode)*d_Id_dV_d_b;
d_staticContributions[admsNodeID_d][admsProbeID_V_g_b] += ((model_.TYPE)*Mode)*d_Id_dV_g_b;
staticContributions[admsNodeID_s] -= (((model_.TYPE)*Mode)*Id);
d_staticContributions[admsNodeID_s][admsProbeID_V_s_b] -= ((model_.TYPE)*Mode)*d_Id_dV_s_b;
d_staticContributions[admsNodeID_s][admsProbeID_V_d_b] -= ((model_.TYPE)*Mode)*d_Id_dV_d_b;
d_staticContributions[admsNodeID_s][admsProbeID_V_g_b] -= ((model_.TYPE)*Mode)*d_Id_dV_g_b;

d_ddt_QD_dV_g_b = (d_QD_dV_g_b);
d_ddt_QD_dV_s_b = (d_QD_dV_s_b);
d_ddt_QD_dV_d_b = (d_QD_dV_d_b);
ddt_QD = (QD);

d_ddt_QS_dV_g_b = (d_QS_dV_g_b);
d_ddt_QS_dV_s_b = (d_QS_dV_s_b);
d_ddt_QS_dV_d_b = (d_QS_dV_d_b);
ddt_QS = (QS);
if ((Mode==1))
{
// I(d,b) <+ ((TYPE*ddt_QD))
staticContributions[admsNodeID_d] += ((model_.TYPE)*ddt_QD);
d_staticContributions[admsNodeID_d][admsProbeID_V_g_b] += (model_.TYPE)*d_ddt_QD_dV_g_b;
d_staticContributions[admsNodeID_d][admsProbeID_V_s_b] += (model_.TYPE)*d_ddt_QD_dV_s_b;
d_staticContributions[admsNodeID_d][admsProbeID_V_d_b] += (model_.TYPE)*d_ddt_QD_dV_d_b;
staticContributions[admsNodeID_b] -= ((model_.TYPE)*ddt_QD);
d_staticContributions[admsNodeID_b][admsProbeID_V_g_b] -= (model_.TYPE)*d_ddt_QD_dV_g_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_s_b] -= (model_.TYPE)*d_ddt_QD_dV_s_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_d_b] -= (model_.TYPE)*d_ddt_QD_dV_d_b;
// I(s,b) <+ ((TYPE*ddt_QS))
staticContributions[admsNodeID_s] += ((model_.TYPE)*ddt_QS);
d_staticContributions[admsNodeID_s][admsProbeID_V_g_b] += (model_.TYPE)*d_ddt_QS_dV_g_b;
d_staticContributions[admsNodeID_s][admsProbeID_V_s_b] += (model_.TYPE)*d_ddt_QS_dV_s_b;
d_staticContributions[admsNodeID_s][admsProbeID_V_d_b] += (model_.TYPE)*d_ddt_QS_dV_d_b;
staticContributions[admsNodeID_b] -= ((model_.TYPE)*ddt_QS);
d_staticContributions[admsNodeID_b][admsProbeID_V_g_b] -= (model_.TYPE)*d_ddt_QS_dV_g_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_s_b] -= (model_.TYPE)*d_ddt_QS_dV_s_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_d_b] -= (model_.TYPE)*d_ddt_QS_dV_d_b;
// I(d,b) <+ ((TYPE*Isub))
staticContributions[admsNodeID_d] += ((model_.TYPE)*Isub);
d_staticContributions[admsNodeID_d][admsProbeID_V_g_b] += (model_.TYPE)*d_Isub_dV_g_b;
d_staticContributions[admsNodeID_d][admsProbeID_V_d_b] += (model_.TYPE)*d_Isub_dV_d_b;
d_staticContributions[admsNodeID_d][admsProbeID_V_s_b] += (model_.TYPE)*d_Isub_dV_s_b;
staticContributions[admsNodeID_b] -= ((model_.TYPE)*Isub);
d_staticContributions[admsNodeID_b][admsProbeID_V_g_b] -= (model_.TYPE)*d_Isub_dV_g_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_d_b] -= (model_.TYPE)*d_Isub_dV_d_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_s_b] -= (model_.TYPE)*d_Isub_dV_s_b;
}
else
{
// I(s,b) <+ ((TYPE*ddt_QD))
staticContributions[admsNodeID_s] += ((model_.TYPE)*ddt_QD);
d_staticContributions[admsNodeID_s][admsProbeID_V_g_b] += (model_.TYPE)*d_ddt_QD_dV_g_b;
d_staticContributions[admsNodeID_s][admsProbeID_V_s_b] += (model_.TYPE)*d_ddt_QD_dV_s_b;
d_staticContributions[admsNodeID_s][admsProbeID_V_d_b] += (model_.TYPE)*d_ddt_QD_dV_d_b;
staticContributions[admsNodeID_b] -= ((model_.TYPE)*ddt_QD);
d_staticContributions[admsNodeID_b][admsProbeID_V_g_b] -= (model_.TYPE)*d_ddt_QD_dV_g_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_s_b] -= (model_.TYPE)*d_ddt_QD_dV_s_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_d_b] -= (model_.TYPE)*d_ddt_QD_dV_d_b;
// I(d,b) <+ ((TYPE*ddt_QS))
staticContributions[admsNodeID_d] += ((model_.TYPE)*ddt_QS);
d_staticContributions[admsNodeID_d][admsProbeID_V_g_b] += (model_.TYPE)*d_ddt_QS_dV_g_b;
d_staticContributions[admsNodeID_d][admsProbeID_V_s_b] += (model_.TYPE)*d_ddt_QS_dV_s_b;
d_staticContributions[admsNodeID_d][admsProbeID_V_d_b] += (model_.TYPE)*d_ddt_QS_dV_d_b;
staticContributions[admsNodeID_b] -= ((model_.TYPE)*ddt_QS);
d_staticContributions[admsNodeID_b][admsProbeID_V_g_b] -= (model_.TYPE)*d_ddt_QS_dV_g_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_s_b] -= (model_.TYPE)*d_ddt_QS_dV_s_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_d_b] -= (model_.TYPE)*d_ddt_QS_dV_d_b;
// I(s,b) <+ ((TYPE*Isub))
staticContributions[admsNodeID_s] += ((model_.TYPE)*Isub);
d_staticContributions[admsNodeID_s][admsProbeID_V_g_b] += (model_.TYPE)*d_Isub_dV_g_b;
d_staticContributions[admsNodeID_s][admsProbeID_V_d_b] += (model_.TYPE)*d_Isub_dV_d_b;
d_staticContributions[admsNodeID_s][admsProbeID_V_s_b] += (model_.TYPE)*d_Isub_dV_s_b;
staticContributions[admsNodeID_b] -= ((model_.TYPE)*Isub);
d_staticContributions[admsNodeID_b][admsProbeID_V_g_b] -= (model_.TYPE)*d_Isub_dV_g_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_d_b] -= (model_.TYPE)*d_Isub_dV_d_b;
d_staticContributions[admsNodeID_b][admsProbeID_V_s_b] -= (model_.TYPE)*d_Isub_dV_s_b;
}
// I(g,b) <+ ((TYPE*ddt(QG)))
dynamicContributions[admsNodeID_g] += ((model_.TYPE)*(QG));
d_dynamicContributions[admsNodeID_g][admsProbeID_V_g_b] += (model_.TYPE)*(d_QG_dV_g_b);
d_dynamicContributions[admsNodeID_g][admsProbeID_V_s_b] += (model_.TYPE)*(d_QG_dV_s_b);
d_dynamicContributions[admsNodeID_g][admsProbeID_V_d_b] += (model_.TYPE)*(d_QG_dV_d_b);
dynamicContributions[admsNodeID_b] -= ((model_.TYPE)*(QG));
d_dynamicContributions[admsNodeID_b][admsProbeID_V_g_b] -= (model_.TYPE)*(d_QG_dV_g_b);
d_dynamicContributions[admsNodeID_b][admsProbeID_V_s_b] -= (model_.TYPE)*(d_QG_dV_s_b);
d_dynamicContributions[admsNodeID_b][admsProbeID_V_d_b] -= (model_.TYPE)*(d_QG_dV_d_b);
if ((model_.Noise))
//Begin block Noise_block
{
//Block-local variables for block Noise_block
double S_flicker=0.0;
double S_thermal=0.0;
//End of Block-local variables
S_thermal = (((4*1.3806226e-23)*T)*Gn);
S_flicker = ((((model_.KF)*gm)*gm)/(((Weff*NS)*Leff)*(model_.COX)));
// I(d,s) <+ (white_noise(S_thermal,"thermal"))
if (getSolverState().noiseFlag)
{
  noiseContribsPower[0]= S_thermal;
}
// I(d,s) <+ (flicker_noise(S_flicker,AF,"flicker"))
if (getSolverState().noiseFlag)
{
  noiseContribsPower[1]= S_flicker;
  noiseContribsExponent[1]= (model_.AF);
}
}
// End block Noise_block
if (((AS==0.0)&&((model_.HDIF)>0.0)))
{
as_i = ((2.0*(model_.HDIF))*Weff);
}
else
{
as_i = AS;
}
if (((PS==0.0)&&((model_.HDIF)>0.0)))
{
ps_i = ((4.0*(model_.HDIF))+(1.0*Weff));
}
else
{
ps_i = PS;
}
if (((AD==0.0)&&((model_.HDIF)>0.0)))
{
ad_i = ((2.0*(model_.HDIF))*Weff);
}
else
{
ad_i = AD;
}
if (((PD==0.0)&&((model_.HDIF)>0.0)))
{
pd_i = ((4.0*(model_.HDIF))+(1.0*Weff));
}
else
{
pd_i = PD;
}
{
double value_log_0 = log(ratioT);
double value_exp_1 = exp(((((refEg/adms_vt(Tnom))-(Eg/Vt))+((model_.tp_xti)*value_log_0))/(model_.xd_n)));
temp_arg = value_exp_1;
}
js_t = ((model_.xd_js)*temp_arg);
jsw_t = ((model_.xd_jsw)*temp_arg);
jswg_t = ((model_.xd_jswg)*temp_arg);
pb_t = ((model_.xd_pb)-((model_.tp_pb)*deltaT));
pbsw_t = ((model_.xd_pbsw)-((model_.tp_pbsw)*deltaT));
pbswg_t = ((model_.xd_pbswg)-((model_.tp_pbswg)*deltaT));
cj_t = ((model_.xd_cj)*(1.0+((model_.tp_cj)*deltaT)));
cjsw_t = ((model_.xd_cjsw)*(1.0+((model_.tp_cjsw)*deltaT)));
cjswg_t = ((model_.xd_cjswg)*(1.0+((model_.tp_cjswg)*deltaT)));
njts_t = ((model_.xd_njts)*(1.0+((ratioT-1.0)*(model_.tp_njts))));
njtssw_t = ((model_.xd_njtssw)*(1.0+((ratioT-1.0)*(model_.tp_njtssw))));
njtsswg_t = ((model_.xd_njtsswg)*(1.0+((ratioT-1.0)*(model_.tp_njtsswg))));

d_v_di_b_dV_d_b = (model_.TYPE)*d_probeVars[admsProbeID_V_d_b][admsProbeID_V_d_b];
v_di_b = ((model_.TYPE)*(probeVars[admsProbeID_V_d_b]));

d_v_si_b_dV_s_b = (model_.TYPE)*d_probeVars[admsProbeID_V_s_b][admsProbeID_V_s_b];
v_si_b = ((model_.TYPE)*(probeVars[admsProbeID_V_s_b]));
is_d = (((js_t*ad_i)+(jsw_t*pd_i))+(jswg_t*Weff));

d_arg_d_dV_d_b = ((-d_v_di_b_dV_d_b)*ratioT/(Vt*(model_.xd_n)));
arg_d = (((-v_di_b)*ratioT)/(Vt*(model_.xd_n)));
if ((arg_d<(-40.0)))
{

d_arg_d_dV_d_b =  0.0;
arg_d = (-40.0);
}

d_tmp0_dV_s_b =  0.0;
d_tmp0_dV_d_b = ((-d_v_di_b_dV_d_b)*ratioT/(Vt*(model_.xd_n)));
tmp0 = ((((-v_di_b)+(model_.xd_bv))*ratioT)/(Vt*(model_.xd_n)));
if ((tmp0>70))
{

d_f_breakdown_d_dV_d_b =  0.0;
f_breakdown_d = 1.0;
}
else
{
{
double value_exp_0 = exp((-tmp0));
double  deriv_exp_0_d0 = value_exp_0;

d_f_breakdown_d_dV_d_b = (model_.xd_xjbv)*(deriv_exp_0_d0*((-d_tmp0_dV_d_b)));
f_breakdown_d = (1.0+((model_.xd_xjbv)*value_exp_0));
}
}
{
double value_max_0 = std::max(((model_.xd_vtsswg)+v_di_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_di_b*ratioT)/(Vt*njtsswg_t))*(model_.xd_vtsswg))/value_max_0));
double  deriv_max_0_d0 = ((((model_.xd_vtsswg)+v_di_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;

d_idb_tun_dV_d_b = ((-Weff)*jswg_t)*(deriv_exp_1_d0*(((value_max_0*(d_v_di_b_dV_d_b*ratioT/(Vt*njtsswg_t))*(model_.xd_vtsswg)-(((v_di_b*ratioT)/(Vt*njtsswg_t))*(model_.xd_vtsswg))*(deriv_max_0_d0*(d_v_di_b_dV_d_b)))/value_max_0/value_max_0)));
idb_tun = (((-Weff)*jswg_t)*(value_exp_1-1.0));
}
{
double value_max_0 = std::max(((model_.xd_vtssw)+v_di_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_di_b*ratioT)/(Vt*njtssw_t))*(model_.xd_vtssw))/value_max_0));
double  deriv_max_0_d0 = ((((model_.xd_vtssw)+v_di_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;

d_idb_tun_dV_d_b = (d_idb_tun_dV_d_b-(pd_i*jsw_t)*(deriv_exp_1_d0*(((value_max_0*(d_v_di_b_dV_d_b*ratioT/(Vt*njtssw_t))*(model_.xd_vtssw)-(((v_di_b*ratioT)/(Vt*njtssw_t))*(model_.xd_vtssw))*(deriv_max_0_d0*(d_v_di_b_dV_d_b)))/value_max_0/value_max_0))));
idb_tun = (idb_tun-((pd_i*jsw_t)*(value_exp_1-1.0)));
}
{
double value_max_0 = std::max(((model_.xd_vts)+v_di_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_di_b*ratioT)/(Vt*njts_t))*(model_.xd_vts))/value_max_0));
double  deriv_max_0_d0 = ((((model_.xd_vts)+v_di_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;

d_idb_tun_dV_d_b = (d_idb_tun_dV_d_b-(ad_i*js_t)*(deriv_exp_1_d0*(((value_max_0*(d_v_di_b_dV_d_b*ratioT/(Vt*njts_t))*(model_.xd_vts)-(((v_di_b*ratioT)/(Vt*njts_t))*(model_.xd_vts))*(deriv_max_0_d0*(d_v_di_b_dV_d_b)))/value_max_0/value_max_0))));
idb_tun = (idb_tun-((ad_i*js_t)*(value_exp_1-1.0)));
}
// I(d,b) <+ (((((((is_d*(1.0-exp(arg_d)))*f_breakdown_d)+(v_di_b*xd_gmin))+idb_tun)*TYPE)*M))
{
double value_exp_0 = exp(arg_d);
double  deriv_exp_0_d0 = value_exp_0;
staticContributions[admsNodeID_d] += ((((((is_d*(1.0-value_exp_0))*f_breakdown_d)+(v_di_b*(model_.xd_gmin)))+idb_tun)*(model_.TYPE))*M);
d_staticContributions[admsNodeID_d][admsProbeID_V_d_b] += ((((is_d*(1.0-value_exp_0))*d_f_breakdown_d_dV_d_b+is_d*(-(deriv_exp_0_d0*(d_arg_d_dV_d_b)))*f_breakdown_d)+d_v_di_b_dV_d_b*(model_.xd_gmin))+d_idb_tun_dV_d_b)*(model_.TYPE)*M;
staticContributions[admsNodeID_b] -= ((((((is_d*(1.0-value_exp_0))*f_breakdown_d)+(v_di_b*(model_.xd_gmin)))+idb_tun)*(model_.TYPE))*M);
d_staticContributions[admsNodeID_b][admsProbeID_V_d_b] -= ((((is_d*(1.0-value_exp_0))*d_f_breakdown_d_dV_d_b+is_d*(-(deriv_exp_0_d0*(d_arg_d_dV_d_b)))*f_breakdown_d)+d_v_di_b_dV_d_b*(model_.xd_gmin))+d_idb_tun_dV_d_b)*(model_.TYPE)*M;
}
is_s = (((js_t*as_i)+(jsw_t*ps_i))+(jswg_t*Weff));

d_arg_s_dV_s_b = ((-d_v_si_b_dV_s_b)*ratioT/(Vt*(model_.xd_n)));
arg_s = (((-v_si_b)*ratioT)/(Vt*(model_.xd_n)));
if ((arg_s<(-40.0)))
{

d_arg_s_dV_s_b =  0.0;
arg_s = (-40.0);
}

d_tmp0_dV_d_b =  0.0;
d_tmp0_dV_s_b = ((-d_v_si_b_dV_s_b)*ratioT/(Vt*(model_.xd_n)));
tmp0 = ((((-v_si_b)+(model_.xd_bv))*ratioT)/(Vt*(model_.xd_n)));
if ((tmp0>70))
{

d_f_breakdown_s_dV_s_b = d_f_breakdown_s_dV_d_b =  0.0;
f_breakdown_s = 1.0;
}
else
{
{
double value_exp_0 = exp((-tmp0));
double  deriv_exp_0_d0 = value_exp_0;

d_f_breakdown_s_dV_d_b = (model_.xd_xjbv)*(deriv_exp_0_d0*((-d_tmp0_dV_d_b)));
d_f_breakdown_s_dV_s_b = (model_.xd_xjbv)*(deriv_exp_0_d0*((-d_tmp0_dV_s_b)));
f_breakdown_s = (1.0+((model_.xd_xjbv)*value_exp_0));
}
}
{
double value_max_0 = std::max(((model_.xd_vtsswg)+v_si_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_si_b*ratioT)/(Vt*njtsswg_t))*(model_.xd_vtsswg))/value_max_0));
double  deriv_max_0_d0 = ((((model_.xd_vtsswg)+v_si_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;

d_isb_tun_dV_s_b = ((-Weff)*jswg_t)*(deriv_exp_1_d0*(((value_max_0*(d_v_si_b_dV_s_b*ratioT/(Vt*njtsswg_t))*(model_.xd_vtsswg)-(((v_si_b*ratioT)/(Vt*njtsswg_t))*(model_.xd_vtsswg))*(deriv_max_0_d0*(d_v_si_b_dV_s_b)))/value_max_0/value_max_0)));
isb_tun = (((-Weff)*jswg_t)*(value_exp_1-1.0));
}
{
double value_max_0 = std::max(((model_.xd_vtssw)+v_si_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_si_b*ratioT)/(Vt*njtssw_t))*(model_.xd_vtssw))/value_max_0));
double  deriv_max_0_d0 = ((((model_.xd_vtssw)+v_si_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;

d_isb_tun_dV_s_b = (d_isb_tun_dV_s_b-(ps_i*jsw_t)*(deriv_exp_1_d0*(((value_max_0*(d_v_si_b_dV_s_b*ratioT/(Vt*njtssw_t))*(model_.xd_vtssw)-(((v_si_b*ratioT)/(Vt*njtssw_t))*(model_.xd_vtssw))*(deriv_max_0_d0*(d_v_si_b_dV_s_b)))/value_max_0/value_max_0))));
isb_tun = (isb_tun-((ps_i*jsw_t)*(value_exp_1-1.0)));
}
{
double value_max_0 = std::max(((model_.xd_vts)+v_si_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_si_b*ratioT)/(Vt*njts_t))*(model_.xd_vts))/value_max_0));
double  deriv_max_0_d0 = ((((model_.xd_vts)+v_si_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;

d_isb_tun_dV_s_b = (d_isb_tun_dV_s_b-(as_i*js_t)*(deriv_exp_1_d0*(((value_max_0*(d_v_si_b_dV_s_b*ratioT/(Vt*njts_t))*(model_.xd_vts)-(((v_si_b*ratioT)/(Vt*njts_t))*(model_.xd_vts))*(deriv_max_0_d0*(d_v_si_b_dV_s_b)))/value_max_0/value_max_0))));
isb_tun = (isb_tun-((as_i*js_t)*(value_exp_1-1.0)));
}
// I(s,b) <+ (((((((is_s*(1.0-exp(arg_s)))*f_breakdown_s)+(v_si_b*xd_gmin))+isb_tun)*TYPE)*M))
{
double value_exp_0 = exp(arg_s);
double  deriv_exp_0_d0 = value_exp_0;
staticContributions[admsNodeID_s] += ((((((is_s*(1.0-value_exp_0))*f_breakdown_s)+(v_si_b*(model_.xd_gmin)))+isb_tun)*(model_.TYPE))*M);
d_staticContributions[admsNodeID_s][admsProbeID_V_d_b] += (is_s*(1.0-value_exp_0))*d_f_breakdown_s_dV_d_b*(model_.TYPE)*M;
d_staticContributions[admsNodeID_s][admsProbeID_V_s_b] += ((((is_s*(1.0-value_exp_0))*d_f_breakdown_s_dV_s_b+is_s*(-(deriv_exp_0_d0*(d_arg_s_dV_s_b)))*f_breakdown_s)+d_v_si_b_dV_s_b*(model_.xd_gmin))+d_isb_tun_dV_s_b)*(model_.TYPE)*M;
staticContributions[admsNodeID_b] -= ((((((is_s*(1.0-value_exp_0))*f_breakdown_s)+(v_si_b*(model_.xd_gmin)))+isb_tun)*(model_.TYPE))*M);
d_staticContributions[admsNodeID_b][admsProbeID_V_d_b] -= (is_s*(1.0-value_exp_0))*d_f_breakdown_s_dV_d_b*(model_.TYPE)*M;
d_staticContributions[admsNodeID_b][admsProbeID_V_s_b] -= ((((is_s*(1.0-value_exp_0))*d_f_breakdown_s_dV_s_b+is_s*(-(deriv_exp_0_d0*(d_arg_s_dV_s_b)))*f_breakdown_s)+d_v_si_b_dV_s_b*(model_.xd_gmin))+d_isb_tun_dV_s_b)*(model_.TYPE)*M;
}
if ((v_di_b>0.0))
{
{
double value_log_0 = log((1.0+(v_di_b/pb_t)));
double value_exp_1 = exp(((-(model_.xd_mj))*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_di_b/pb_t)));
double  deriv_exp_1_d0 = value_exp_1;

d_csb_d_dV_d_b = (cj_t*ad_i)*(deriv_exp_1_d0*((-(model_.xd_mj))*(deriv_log_0_d0*((d_v_di_b_dV_d_b/pb_t)))));
csb_d = ((cj_t*ad_i)*value_exp_1);
}
{
double value_log_0 = log((1.0+(v_di_b/pbsw_t)));
double value_exp_1 = exp(((-(model_.xd_mjsw))*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_di_b/pbsw_t)));
double  deriv_exp_1_d0 = value_exp_1;

d_cssw_d_dV_d_b = (cjsw_t*pd_i)*(deriv_exp_1_d0*((-(model_.xd_mjsw))*(deriv_log_0_d0*((d_v_di_b_dV_d_b/pbsw_t)))));
cssw_d = ((cjsw_t*pd_i)*value_exp_1);
}
{
double value_log_0 = log((1.0+(v_di_b/pbswg_t)));
double value_exp_1 = exp(((-(model_.xd_mjswg))*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_di_b/pbswg_t)));
double  deriv_exp_1_d0 = value_exp_1;

d_csswg_d_dV_d_b = (cjswg_t*Weff)*(deriv_exp_1_d0*((-(model_.xd_mjswg))*(deriv_log_0_d0*((d_v_di_b_dV_d_b/pbswg_t)))));
csswg_d = ((cjswg_t*Weff)*value_exp_1);
}
}
else
{

d_csb_d_dV_d_b = (cj_t*ad_i)*(-((model_.xd_mj)*d_v_di_b_dV_d_b/pb_t));
csb_d = ((cj_t*ad_i)*(1.0-(((model_.xd_mj)*v_di_b)/pb_t)));

d_cssw_d_dV_d_b = (cjsw_t*pd_i)*(-((model_.xd_mjsw)*d_v_di_b_dV_d_b/pbsw_t));
cssw_d = ((cjsw_t*pd_i)*(1.0-(((model_.xd_mjsw)*v_di_b)/pbsw_t)));

d_csswg_d_dV_d_b = (cjswg_t*Weff)*(-((model_.xd_mjswg)*d_v_di_b_dV_d_b/pbswg_t));
csswg_d = ((cjswg_t*Weff)*(1.0-(((model_.xd_mjswg)*v_di_b)/pbswg_t)));
}

d_qjd_dV_d_b = (((csb_d+cssw_d)+csswg_d)*d_v_di_b_dV_d_b+((d_csb_d_dV_d_b+d_cssw_d_dV_d_b)+d_csswg_d_dV_d_b)*v_di_b);
qjd = (((csb_d+cssw_d)+csswg_d)*v_di_b);
// I(d,b) <+ (((ddt(qjd)*TYPE)*M))
dynamicContributions[admsNodeID_d] += (((qjd)*(model_.TYPE))*M);
d_dynamicContributions[admsNodeID_d][admsProbeID_V_d_b] += (d_qjd_dV_d_b)*(model_.TYPE)*M;
dynamicContributions[admsNodeID_b] -= (((qjd)*(model_.TYPE))*M);
d_dynamicContributions[admsNodeID_b][admsProbeID_V_d_b] -= (d_qjd_dV_d_b)*(model_.TYPE)*M;
if ((v_si_b>0.0))
{
{
double value_log_0 = log((1.0+(v_si_b/pb_t)));
double value_exp_1 = exp(((-(model_.xd_mj))*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_si_b/pb_t)));
double  deriv_exp_1_d0 = value_exp_1;

d_csb_s_dV_s_b = (cj_t*as_i)*(deriv_exp_1_d0*((-(model_.xd_mj))*(deriv_log_0_d0*((d_v_si_b_dV_s_b/pb_t)))));
csb_s = ((cj_t*as_i)*value_exp_1);
}
{
double value_log_0 = log((1.0+(v_si_b/pbsw_t)));
double value_exp_1 = exp(((-(model_.xd_mjsw))*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_si_b/pbsw_t)));
double  deriv_exp_1_d0 = value_exp_1;

d_cssw_s_dV_s_b = (cjsw_t*ps_i)*(deriv_exp_1_d0*((-(model_.xd_mjsw))*(deriv_log_0_d0*((d_v_si_b_dV_s_b/pbsw_t)))));
cssw_s = ((cjsw_t*ps_i)*value_exp_1);
}
{
double value_log_0 = log((1.0+(v_si_b/pbswg_t)));
double value_exp_1 = exp(((-(model_.xd_mjswg))*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_si_b/pbswg_t)));
double  deriv_exp_1_d0 = value_exp_1;

d_csswg_s_dV_s_b = (cjswg_t*Weff)*(deriv_exp_1_d0*((-(model_.xd_mjswg))*(deriv_log_0_d0*((d_v_si_b_dV_s_b/pbswg_t)))));
csswg_s = ((cjswg_t*Weff)*value_exp_1);
}
}
else
{

d_csb_s_dV_s_b = (cj_t*as_i)*(-((model_.xd_mj)*d_v_si_b_dV_s_b/pb_t));
csb_s = ((cj_t*as_i)*(1.0-(((model_.xd_mj)*v_si_b)/pb_t)));

d_cssw_s_dV_s_b = (cjsw_t*ps_i)*(-((model_.xd_mjsw)*d_v_si_b_dV_s_b/pbsw_t));
cssw_s = ((cjsw_t*ps_i)*(1.0-(((model_.xd_mjsw)*v_si_b)/pbsw_t)));

d_csswg_s_dV_s_b = (cjswg_t*Weff)*(-((model_.xd_mjswg)*d_v_si_b_dV_s_b/pbswg_t));
csswg_s = ((cjswg_t*Weff)*(1.0-(((model_.xd_mjswg)*v_si_b)/pbswg_t)));
}

d_qjs_dV_s_b = (((csb_s+cssw_s)+csswg_s)*d_v_si_b_dV_s_b+((d_csb_s_dV_s_b+d_cssw_s_dV_s_b)+d_csswg_s_dV_s_b)*v_si_b);
qjs = (((csb_s+cssw_s)+csswg_s)*v_si_b);
// I(s,b) <+ (((ddt(qjs)*TYPE)*M))
dynamicContributions[admsNodeID_s] += (((qjs)*(model_.TYPE))*M);
d_dynamicContributions[admsNodeID_s][admsProbeID_V_s_b] += (d_qjs_dV_s_b)*(model_.TYPE)*M;
dynamicContributions[admsNodeID_b] -= (((qjs)*(model_.TYPE))*M);
d_dynamicContributions[admsNodeID_b][admsProbeID_V_s_b] -= (d_qjs_dV_s_b)*(model_.TYPE)*M;


  // -- endcode converted from analog/code block
  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && getSolverState().debugTimeFlag)
  {
    Xyce::dout() << " probeVars[admsProbeID_V_d_b] =  "
         <<probeVars[admsProbeID_V_d_b] << std::endl;
    Xyce::dout() << " probeVars[admsProbeID_V_s_b] =  "
         <<probeVars[admsProbeID_V_s_b] << std::endl;
    Xyce::dout() << " probeVars[admsProbeID_V_g_b] =  "
         <<probeVars[admsProbeID_V_g_b] << std::endl;
    Xyce::dout() << " staticContributions[admsNodeID_d] =  "
         <<staticContributions[admsNodeID_d] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_d].dx(admsProbeID_V_d_b) =  " <<d_staticContributions[admsNodeID_d][admsProbeID_V_d_b] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_d].dx(admsProbeID_V_s_b) =  " <<d_staticContributions[admsNodeID_d][admsProbeID_V_s_b] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_d].dx(admsProbeID_V_g_b) =  " <<d_staticContributions[admsNodeID_d][admsProbeID_V_g_b] << std::endl;
    Xyce::dout() << " dynamicContributions[admsNodeID_d] =  "
         <<dynamicContributions[admsNodeID_d] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_d].dx(admsProbeID_V_d_b) =  " <<d_dynamicContributions[admsNodeID_d][admsProbeID_V_d_b] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_d].dx(admsProbeID_V_s_b) =  " <<d_dynamicContributions[admsNodeID_d][admsProbeID_V_s_b] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_d].dx(admsProbeID_V_g_b) =  " <<d_dynamicContributions[admsNodeID_d][admsProbeID_V_g_b] << std::endl;
    Xyce::dout() << " staticContributions[admsNodeID_g] =  "
         <<staticContributions[admsNodeID_g] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_g].dx(admsProbeID_V_d_b) =  " <<d_staticContributions[admsNodeID_g][admsProbeID_V_d_b] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_g].dx(admsProbeID_V_s_b) =  " <<d_staticContributions[admsNodeID_g][admsProbeID_V_s_b] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_g].dx(admsProbeID_V_g_b) =  " <<d_staticContributions[admsNodeID_g][admsProbeID_V_g_b] << std::endl;
    Xyce::dout() << " dynamicContributions[admsNodeID_g] =  "
         <<dynamicContributions[admsNodeID_g] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_g].dx(admsProbeID_V_d_b) =  " <<d_dynamicContributions[admsNodeID_g][admsProbeID_V_d_b] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_g].dx(admsProbeID_V_s_b) =  " <<d_dynamicContributions[admsNodeID_g][admsProbeID_V_s_b] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_g].dx(admsProbeID_V_g_b) =  " <<d_dynamicContributions[admsNodeID_g][admsProbeID_V_g_b] << std::endl;
    Xyce::dout() << " staticContributions[admsNodeID_s] =  "
         <<staticContributions[admsNodeID_s] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_s].dx(admsProbeID_V_d_b) =  " <<d_staticContributions[admsNodeID_s][admsProbeID_V_d_b] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_s].dx(admsProbeID_V_s_b) =  " <<d_staticContributions[admsNodeID_s][admsProbeID_V_s_b] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_s].dx(admsProbeID_V_g_b) =  " <<d_staticContributions[admsNodeID_s][admsProbeID_V_g_b] << std::endl;
    Xyce::dout() << " dynamicContributions[admsNodeID_s] =  "
         <<dynamicContributions[admsNodeID_s] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_s].dx(admsProbeID_V_d_b) =  " <<d_dynamicContributions[admsNodeID_s][admsProbeID_V_d_b] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_s].dx(admsProbeID_V_s_b) =  " <<d_dynamicContributions[admsNodeID_s][admsProbeID_V_s_b] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_s].dx(admsProbeID_V_g_b) =  " <<d_dynamicContributions[admsNodeID_s][admsProbeID_V_g_b] << std::endl;
    Xyce::dout() << " staticContributions[admsNodeID_b] =  "
         <<staticContributions[admsNodeID_b] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_b].dx(admsProbeID_V_d_b) =  " <<d_staticContributions[admsNodeID_b][admsProbeID_V_d_b] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_b].dx(admsProbeID_V_s_b) =  " <<d_staticContributions[admsNodeID_b][admsProbeID_V_s_b] << std::endl;
      Xyce::dout() << "    staticContributions[admsNodeID_b].dx(admsProbeID_V_g_b) =  " <<d_staticContributions[admsNodeID_b][admsProbeID_V_g_b] << std::endl;
    Xyce::dout() << " dynamicContributions[admsNodeID_b] =  "
         <<dynamicContributions[admsNodeID_b] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_b].dx(admsProbeID_V_d_b) =  " <<d_dynamicContributions[admsNodeID_b][admsProbeID_V_d_b] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_b].dx(admsProbeID_V_s_b) =  " <<d_dynamicContributions[admsNodeID_b][admsProbeID_V_s_b] << std::endl;
      Xyce::dout() << "    dynamicContributions[admsNodeID_b].dx(admsProbeID_V_g_b) =  " <<d_dynamicContributions[admsNodeID_b][admsProbeID_V_g_b] << std::endl;

    if (!origFlag)
      Xyce::dout() << "This step was limited by this device." << std::endl;
  }


  if (loadLeadCurrent)
  {
    // If needed, we must now copy all the data from staticContributions
    // and dynamicContributionsinto the lead current F vector
    // Must make sure all collapsed node contributions get summed into the
    // external nodes properly.
    for ( int unmappedNode=0; unmappedNode < 4 ; unmappedNode++)
    {
      leadCurrentF[unmappedNode] = 0.0;
      leadCurrentQ[unmappedNode] = 0.0;
    }
    for ( int unmappedNode=0; unmappedNode < 4; unmappedNode++)
    {
      if (nodeMap[unmappedNode] < 4 && nodeMap[unmappedNode] != -1 )
      {
        leadCurrentF[nodeMap[unmappedNode]] += staticContributions[unmappedNode];
        leadCurrentQ[nodeMap[unmappedNode]] += dynamicContributions[unmappedNode];
      }
    }
  }
  return true;
}

//-----------------------------------------------------------------------------
// Function      : Instance::getNumNoiseSources
// Purpose       :
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
int Instance::getNumNoiseSources () const
{
return 2;
}

//-----------------------------------------------------------------------------
// Function      : Instance::setupNoiseSources
// Purpose       :
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
void Instance::setupNoiseSources (Xyce::Analysis::NoiseData & noiseData)
{
int numSources=getNumNoiseSources();
noiseData.numSources = numSources;
noiseData.resize(numSources);

noiseData.deviceName = getName().getEncodedName();
std::string theNoiseName;
theNoiseName = std::string("noise_")+getName().getEncodedName()+std::string("_white_d_s")+std::string("_")+std::string("thermal");
std::replace(theNoiseName.begin(), theNoiseName.end(), ' ', '_');
noiseData.noiseNames[0]=theNoiseName;
noiseData.li_Pos[0]=li_d;
noiseData.li_Neg[0]=li_s;
theNoiseName = std::string("noise_")+getName().getEncodedName()+std::string("_flicker_d_s")+std::string("_")+std::string("flicker");
std::replace(theNoiseName.begin(), theNoiseName.end(), ' ', '_');
noiseData.noiseNames[1]=theNoiseName;
noiseData.li_Pos[1]=li_d;
noiseData.li_Neg[1]=li_s;


}
//-----------------------------------------------------------------------------
// Function      : Instance::getNoiseSources
// Purpose       :
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
void Instance::getNoiseSources (Xyce::Analysis::NoiseData & noiseData)
{noiseData.noiseDens[0] = noiseContribsPower[0];
noiseData.lnNoiseDens[0] = std::log(std::max(noiseData.noiseDens[0],N_MINLOG));
noiseData.noiseDens[1] = noiseContribsPower[1];

      noiseData.noiseDens[1] /= pow(noiseData.freq,noiseContribsExponent[1]);noiseData.lnNoiseDens[1] = std::log(std::max(noiseData.noiseDens[1],N_MINLOG));

}

//-----------------------------------------------------------------------------
// Function      : Instance::loadDAEdFdx
// Purpose       :
// Special Notes : Load the dFdx ("static jacobian") matrix
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
bool Instance::loadDAEdFdx()
{
  bool bsuccess = true;
  Linear::Matrix & dFdx = *(extData.dFdxMatrixPtr);

#ifndef Xyce_NONPOINTER_MATRIX_LOAD
  (*f_d_Equ_s_Node_Ptr) +=  +d_staticContributions[admsNodeID_d][admsProbeID_V_s_b];
  (*f_d_Equ_b_Node_Ptr) +=  -d_staticContributions[admsNodeID_d][admsProbeID_V_g_b] -d_staticContributions[admsNodeID_d][admsProbeID_V_d_b] -d_staticContributions[admsNodeID_d][admsProbeID_V_s_b];
  (*f_s_Equ_s_Node_Ptr) +=  +d_staticContributions[admsNodeID_s][admsProbeID_V_s_b];
  (*f_s_Equ_b_Node_Ptr) +=  -d_staticContributions[admsNodeID_s][admsProbeID_V_g_b] -d_staticContributions[admsNodeID_s][admsProbeID_V_d_b] -d_staticContributions[admsNodeID_s][admsProbeID_V_s_b];
  (*f_d_Equ_d_Node_Ptr) +=  +d_staticContributions[admsNodeID_d][admsProbeID_V_d_b];
  (*f_s_Equ_d_Node_Ptr) +=  +d_staticContributions[admsNodeID_s][admsProbeID_V_d_b];
  (*f_d_Equ_g_Node_Ptr) +=  +d_staticContributions[admsNodeID_d][admsProbeID_V_g_b];
  (*f_s_Equ_g_Node_Ptr) +=  +d_staticContributions[admsNodeID_s][admsProbeID_V_g_b];
  (*f_b_Equ_g_Node_Ptr) +=  +d_staticContributions[admsNodeID_b][admsProbeID_V_g_b];
  (*f_b_Equ_b_Node_Ptr) +=  -d_staticContributions[admsNodeID_b][admsProbeID_V_d_b] -d_staticContributions[admsNodeID_b][admsProbeID_V_s_b] -d_staticContributions[admsNodeID_b][admsProbeID_V_g_b];
  (*f_b_Equ_s_Node_Ptr) +=  +d_staticContributions[admsNodeID_b][admsProbeID_V_s_b];
  (*f_b_Equ_d_Node_Ptr) +=  +d_staticContributions[admsNodeID_b][admsProbeID_V_d_b];

#else
  //use the offsets instead of pointers
  dFdx[li_d][A_d_Equ_s_NodeOffset] +=  +d_staticContributions[admsNodeID_d][admsProbeID_V_s_b];
  dFdx[li_d][A_d_Equ_b_NodeOffset] +=  -d_staticContributions[admsNodeID_d][admsProbeID_V_g_b] -d_staticContributions[admsNodeID_d][admsProbeID_V_d_b] -d_staticContributions[admsNodeID_d][admsProbeID_V_s_b];
  dFdx[li_s][A_s_Equ_s_NodeOffset] +=  +d_staticContributions[admsNodeID_s][admsProbeID_V_s_b];
  dFdx[li_s][A_s_Equ_b_NodeOffset] +=  -d_staticContributions[admsNodeID_s][admsProbeID_V_g_b] -d_staticContributions[admsNodeID_s][admsProbeID_V_d_b] -d_staticContributions[admsNodeID_s][admsProbeID_V_s_b];
  dFdx[li_d][A_d_Equ_d_NodeOffset] +=  +d_staticContributions[admsNodeID_d][admsProbeID_V_d_b];
  dFdx[li_s][A_s_Equ_d_NodeOffset] +=  +d_staticContributions[admsNodeID_s][admsProbeID_V_d_b];
  dFdx[li_d][A_d_Equ_g_NodeOffset] +=  +d_staticContributions[admsNodeID_d][admsProbeID_V_g_b];
  dFdx[li_s][A_s_Equ_g_NodeOffset] +=  +d_staticContributions[admsNodeID_s][admsProbeID_V_g_b];
  dFdx[li_b][A_b_Equ_g_NodeOffset] +=  +d_staticContributions[admsNodeID_b][admsProbeID_V_g_b];
  dFdx[li_b][A_b_Equ_b_NodeOffset] +=  -d_staticContributions[admsNodeID_b][admsProbeID_V_d_b] -d_staticContributions[admsNodeID_b][admsProbeID_V_s_b] -d_staticContributions[admsNodeID_b][admsProbeID_V_g_b];
  dFdx[li_b][A_b_Equ_s_NodeOffset] +=  +d_staticContributions[admsNodeID_b][admsProbeID_V_s_b];
  dFdx[li_b][A_b_Equ_d_NodeOffset] +=  +d_staticContributions[admsNodeID_b][admsProbeID_V_d_b];

#endif

  return bsuccess;
}


//-----------------------------------------------------------------------------
// Function      : Instance::loadDAEdQdx
// Purpose       :
// Special Notes : Load the dQdx ("dynamic jacobian") matrix
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
bool Instance::loadDAEdQdx()
{
  bool bsuccess = true;
  Linear::Matrix & dQdx = *(extData.dQdxMatrixPtr);

#ifndef Xyce_NONPOINTER_MATRIX_LOAD
  (*q_d_Equ_b_Node_Ptr) +=  -d_dynamicContributions[admsNodeID_d][admsProbeID_V_d_b];
  (*q_s_Equ_s_Node_Ptr) +=  +d_dynamicContributions[admsNodeID_s][admsProbeID_V_s_b];
  (*q_s_Equ_b_Node_Ptr) +=  -d_dynamicContributions[admsNodeID_s][admsProbeID_V_s_b];
  (*q_d_Equ_d_Node_Ptr) +=  +d_dynamicContributions[admsNodeID_d][admsProbeID_V_d_b];
  (*q_b_Equ_g_Node_Ptr) +=  +d_dynamicContributions[admsNodeID_b][admsProbeID_V_g_b];
  (*q_b_Equ_b_Node_Ptr) +=  -d_dynamicContributions[admsNodeID_b][admsProbeID_V_d_b] -d_dynamicContributions[admsNodeID_b][admsProbeID_V_s_b] -d_dynamicContributions[admsNodeID_b][admsProbeID_V_g_b];
  (*q_b_Equ_s_Node_Ptr) +=  +d_dynamicContributions[admsNodeID_b][admsProbeID_V_s_b];
  (*q_b_Equ_d_Node_Ptr) +=  +d_dynamicContributions[admsNodeID_b][admsProbeID_V_d_b];
  (*q_g_Equ_g_Node_Ptr) +=  +d_dynamicContributions[admsNodeID_g][admsProbeID_V_g_b];
  (*q_g_Equ_b_Node_Ptr) +=  -d_dynamicContributions[admsNodeID_g][admsProbeID_V_d_b] -d_dynamicContributions[admsNodeID_g][admsProbeID_V_s_b] -d_dynamicContributions[admsNodeID_g][admsProbeID_V_g_b];
  (*q_g_Equ_s_Node_Ptr) +=  +d_dynamicContributions[admsNodeID_g][admsProbeID_V_s_b];
  (*q_g_Equ_d_Node_Ptr) +=  +d_dynamicContributions[admsNodeID_g][admsProbeID_V_d_b];

#else
  //use the offsets instead of pointers
  dQdx[li_d][A_d_Equ_b_NodeOffset] +=  -d_dynamicContributions[admsNodeID_d][admsProbeID_V_d_b];
  dQdx[li_s][A_s_Equ_s_NodeOffset] +=  +d_dynamicContributions[admsNodeID_s][admsProbeID_V_s_b];
  dQdx[li_s][A_s_Equ_b_NodeOffset] +=  -d_dynamicContributions[admsNodeID_s][admsProbeID_V_s_b];
  dQdx[li_d][A_d_Equ_d_NodeOffset] +=  +d_dynamicContributions[admsNodeID_d][admsProbeID_V_d_b];
  dQdx[li_b][A_b_Equ_g_NodeOffset] +=  +d_dynamicContributions[admsNodeID_b][admsProbeID_V_g_b];
  dQdx[li_b][A_b_Equ_b_NodeOffset] +=  -d_dynamicContributions[admsNodeID_b][admsProbeID_V_d_b] -d_dynamicContributions[admsNodeID_b][admsProbeID_V_s_b] -d_dynamicContributions[admsNodeID_b][admsProbeID_V_g_b];
  dQdx[li_b][A_b_Equ_s_NodeOffset] +=  +d_dynamicContributions[admsNodeID_b][admsProbeID_V_s_b];
  dQdx[li_b][A_b_Equ_d_NodeOffset] +=  +d_dynamicContributions[admsNodeID_b][admsProbeID_V_d_b];
  dQdx[li_g][A_g_Equ_g_NodeOffset] +=  +d_dynamicContributions[admsNodeID_g][admsProbeID_V_g_b];
  dQdx[li_g][A_g_Equ_b_NodeOffset] +=  -d_dynamicContributions[admsNodeID_g][admsProbeID_V_d_b] -d_dynamicContributions[admsNodeID_g][admsProbeID_V_s_b] -d_dynamicContributions[admsNodeID_g][admsProbeID_V_g_b];
  dQdx[li_g][A_g_Equ_s_NodeOffset] +=  +d_dynamicContributions[admsNodeID_g][admsProbeID_V_s_b];
  dQdx[li_g][A_g_Equ_d_NodeOffset] +=  +d_dynamicContributions[admsNodeID_g][admsProbeID_V_d_b];


#endif
  return bsuccess;
}




//-----------------------------------------------------------------------------
// Function      : Instance::updateTemperature
// Purpose       : Set temperature and update any parameters that depend on it
// Special Notes : In Xyce ADMS, we'll simply copy the temperature, which is
//                 in Kelvin, to our "admsTemperature" variable, which needs
//                 to be in Celsius.
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
bool Instance::updateTemperature(const double & temperatureTemp)
{

  admsTemperature = temperatureTemp;
  adms_vt_nom = adms_vt(temperatureTemp);

  return true;
}

// Class Model
//-----------------------------------------------------------------------------
// Function      : Model::processParams
// Purpose       :
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
bool Model::processParams()
{

  // Set any non-constant parameter defaults:
  // Set any parameters that were not given and whose defaults depend on other
  // parameters:

// set internal model type based on model card type
if (getType() == "pmos" || getType() == "PMOS")
    TYPE = -1;



  // Now we need to check that any parameters are within their ranges as
  // specified in the verilog:

//    Parameter TYPE : [ (-1), 1 ]] 0, 0 [
  if ( (!((TYPE >=(-1) && TYPE <=1 )) || (TYPE >0 && TYPE <0 )) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter TYPE value " << TYPE << " out of range [ (-1), 1 ] or  ] 0, 0 [";
  }

//    Parameter Noise : [ 0, 1 ]
  if ( (!((Noise >=0 && Noise <=1 ))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter Noise value " << Noise << " out of range [ 0, 1 ]";
  }

//    Parameter Trise :  ] (-inf)  (+inf) [

//    Parameter TEMP : [ (-273.15),  (+inf) [
  if ( (!((TEMP >=(-273.15)))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter TEMP value " << TEMP << " out of range [ (-273.15),  (+inf) [";
  }

//    Parameter L : [ 0.0,  (+inf) [
  if ( (!((L >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter L value " << L << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter W : [ 0.0,  (+inf) [
  if ( (!((W >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter W value " << W << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter M : [ 0.0,  (+inf) [
  if ( (!((M >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter M value " << M << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter NS : [ 0.0,  (+inf) [
  if ( (!((NS >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter NS value " << NS << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter AS : [ 0.0,  (+inf) [
  if ( (!((AS >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter AS value " << AS << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter AD : [ 0.0,  (+inf) [
  if ( (!((AD >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter AD value " << AD << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter PS : [ 0.0,  (+inf) [
  if ( (!((PS >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter PS value " << PS << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter PD : [ 0.0,  (+inf) [
  if ( (!((PD >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter PD value " << PD << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter COX : [ 0.0,  (+inf) [
  if ( (!((COX >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter COX value " << COX << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter XJ : [ 0.0,  (+inf) [
  if ( (!((XJ >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter XJ value " << XJ << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter VTO :  ] (-inf)  (+inf) [

//    Parameter GAMMA : [ 0.0,  (+inf) [
  if ( (!((GAMMA >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter GAMMA value " << GAMMA << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter PHI : [ 0.2,  (+inf) [
  if ( (!((PHI >=0.2))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter PHI value " << PHI << " out of range [ 0.2,  (+inf) [";
  }

//    Parameter KP : [ 0.0,  (+inf) [
  if ( (!((KP >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter KP value " << KP << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter THETA : [ 0.0,  (+inf) [
  if ( (!((THETA >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter THETA value " << THETA << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter UCRIT : [ 0.0,  (+inf) [
  if ( (!((UCRIT >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter UCRIT value " << UCRIT << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter LAMBDA : [ 0.0,  (+inf) [
  if ( (!((LAMBDA >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter LAMBDA value " << LAMBDA << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter WETA : [ 0.0,  (+inf) [
  if ( (!((WETA >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter WETA value " << WETA << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter LETA : [ 0.0,  (+inf) [
  if ( (!((LETA >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter LETA value " << LETA << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter Q0 : [ 0.0,  (+inf) [
  if ( (!((Q0 >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter Q0 value " << Q0 << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter LK : [ 0.0,  (+inf) [
  if ( (!((LK >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter LK value " << LK << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter IBA : [ 0.0,  (+inf) [
  if ( (!((IBA >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter IBA value " << IBA << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter IBB : [ 0.0,  (+inf) [
  if ( (!((IBB >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter IBB value " << IBB << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter IBN : [ 0.0,  (+inf) [
  if ( (!((IBN >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter IBN value " << IBN << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter RSH : [ 0.0,  (+inf) [
  if ( (!((RSH >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter RSH value " << RSH << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter HDIF : [ 0.0,  (+inf) [
  if ( (!((HDIF >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter HDIF value " << HDIF << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter AVTO : [ 0.0,  (+inf) [
  if ( (!((AVTO >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter AVTO value " << AVTO << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter AKP : [ 0.0,  (+inf) [
  if ( (!((AKP >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter AKP value " << AKP << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter AGAMMA : [ 0.0,  (+inf) [
  if ( (!((AGAMMA >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter AGAMMA value " << AGAMMA << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter AF : ] 0,  (+inf) [
  if ( (!((AF >0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter AF value " << AF << " out of range ] 0,  (+inf) [";
  }

//    Parameter KF : [ 0,  (+inf) [
  if ( (!((KF >=0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter KF value " << KF << " out of range [ 0,  (+inf) [";
  }

//    Parameter xd_n : [ 0.0,  (+inf) [
  if ( (!((xd_n >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_n value " << xd_n << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_js : [ 0.0,  (+inf) [
  if ( (!((xd_js >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_js value " << xd_js << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_jsw : [ 0.0,  (+inf) [
  if ( (!((xd_jsw >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_jsw value " << xd_jsw << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_jswg : [ 0.0,  (+inf) [
  if ( (!((xd_jswg >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_jswg value " << xd_jswg << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_mj : [ 0.0, 1.0 ]
  if ( (!((xd_mj >=0.0 && xd_mj <=1.0 ))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_mj value " << xd_mj << " out of range [ 0.0, 1.0 ]";
  }

//    Parameter xd_mjsw : [ 0.0, 1.0 ]
  if ( (!((xd_mjsw >=0.0 && xd_mjsw <=1.0 ))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_mjsw value " << xd_mjsw << " out of range [ 0.0, 1.0 ]";
  }

//    Parameter xd_mjswg : [ 0.0, 1.0 ]
  if ( (!((xd_mjswg >=0.0 && xd_mjswg <=1.0 ))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_mjswg value " << xd_mjswg << " out of range [ 0.0, 1.0 ]";
  }

//    Parameter xd_pb : ] 0.0,  (+inf) [
  if ( (!((xd_pb >0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_pb value " << xd_pb << " out of range ] 0.0,  (+inf) [";
  }

//    Parameter xd_pbsw : ] 0.0,  (+inf) [
  if ( (!((xd_pbsw >0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_pbsw value " << xd_pbsw << " out of range ] 0.0,  (+inf) [";
  }

//    Parameter xd_pbswg : ] 0.0,  (+inf) [
  if ( (!((xd_pbswg >0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_pbswg value " << xd_pbswg << " out of range ] 0.0,  (+inf) [";
  }

//    Parameter xd_cj : [ 0.0,  (+inf) [
  if ( (!((xd_cj >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_cj value " << xd_cj << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_cjsw : [ 0.0,  (+inf) [
  if ( (!((xd_cjsw >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_cjsw value " << xd_cjsw << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_cjswg : [ 0.0,  (+inf) [
  if ( (!((xd_cjswg >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_cjswg value " << xd_cjswg << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_gmin : [ 0.0,  (+inf) [
  if ( (!((xd_gmin >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_gmin value " << xd_gmin << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_xjbv : [ 0.0,  (+inf) [
  if ( (!((xd_xjbv >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_xjbv value " << xd_xjbv << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_bv : [ 0.0,  (+inf) [
  if ( (!((xd_bv >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_bv value " << xd_bv << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_njts : [ 0.0,  (+inf) [
  if ( (!((xd_njts >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_njts value " << xd_njts << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_njtssw : [ 0.0,  (+inf) [
  if ( (!((xd_njtssw >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_njtssw value " << xd_njtssw << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_njtsswg : [ 0.0,  (+inf) [
  if ( (!((xd_njtsswg >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_njtsswg value " << xd_njtsswg << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_vts : [ 0.0,  (+inf) [
  if ( (!((xd_vts >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_vts value " << xd_vts << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_vtssw : [ 0.0,  (+inf) [
  if ( (!((xd_vtssw >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_vtssw value " << xd_vtssw << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter xd_vtsswg : [ 0.0,  (+inf) [
  if ( (!((xd_vtsswg >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter xd_vtsswg value " << xd_vtsswg << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter tp_xti :  ] (-inf)  (+inf) [

//    Parameter tp_cj :  ] (-inf)  (+inf) [

//    Parameter tp_cjsw :  ] (-inf)  (+inf) [

//    Parameter tp_cjswg :  ] (-inf)  (+inf) [

//    Parameter tp_pb :  ] (-inf)  (+inf) [

//    Parameter tp_pbsw :  ] (-inf)  (+inf) [

//    Parameter tp_pbswg :  ] (-inf)  (+inf) [

//    Parameter tp_njts : [ 0.0,  (+inf) [
  if ( (!((tp_njts >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter tp_njts value " << tp_njts << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter tp_njtssw : [ 0.0,  (+inf) [
  if ( (!((tp_njtssw >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter tp_njtssw value " << tp_njtssw << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter tp_njtsswg : [ 0.0,  (+inf) [
  if ( (!((tp_njtsswg >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter tp_njtsswg value " << tp_njtsswg << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter LMIN : [ 0.0,  (+inf) [
  if ( (!((LMIN >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter LMIN value " << LMIN << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter LMAX : [ 0,  (+inf) [
  if ( (!((LMAX >=0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter LMAX value " << LMAX << " out of range [ 0,  (+inf) [";
  }

//    Parameter WMIN : [ 0.0,  (+inf) [
  if ( (!((WMIN >=0.0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter WMIN value " << WMIN << " out of range [ 0.0,  (+inf) [";
  }

//    Parameter WMAX : [ 0,  (+inf) [
  if ( (!((WMAX >=0))) )
  {
    UserWarning(*this) << "ADMSekv_va: Parameter WMAX value " << WMAX << " out of range [ 0,  (+inf) [";
  }

  // and of course, this routine is where we should put the initial_model
  // stuff


  return true;
}
//----------------------------------------------------------------------------
// Function      : Model::processInstanceParams
// Purpose       :
// Special Notes :
// Scope         : public
// Creator       :
// Creation Date :
//----------------------------------------------------------------------------
bool Model::processInstanceParams()
{

  std::vector<Instance*>::iterator iter;
  std::vector<Instance*>::iterator first = instanceContainer.begin();
  std::vector<Instance*>::iterator last  = instanceContainer.end();

  for (iter=first; iter!=last; ++iter)
  {
    (*iter)->processParams();
  }

  return true;
}

//-----------------------------------------------------------------------------
// Function      : Model::Model
// Purpose       : model block constructor
// Special Notes :
// Scope         : public
// Creator       :
// Creation Date :
//-----------------------------------------------------------------------------
Model::Model(
  const Configuration & configuration,
  const ModelBlock &    model_block,
  const FactoryBlock &  factory_block)
  : DeviceModel(model_block, configuration.getModelParameters(), factory_block),
    TYPE(1),
    Noise(1),
    Trise(0.0),
    TEMP(1.0e21),
    TNOM(1.0e21),
    L(10E-6),
    W(10E-6),
    M(1.0),
    NS(1.0),
    AS(0.0),
    AD(0.0),
    PS(0.0),
    PD(0.0),
    COX(2.0E-3),
    XJ(300E-9),
    VTO(0.5),
    TCV(1.0e-3),
    GAMMA(0.7),
    PHI(0.5),
    KP(150E-6),
    BEX((-1.5)),
    THETA(0.0),
    E0(1.0E8),
    UCRIT(2.0E6),
    UCEX(0.8),
    LAMBDA(0.8),
    DL((-0.01E-6)),
    DW((-0.01E-6)),
    WETA(0.2),
    LETA(0.3),
    Q0(230E-6),
    LK(0.4E-6),
    IBA(5.0E8),
    IBB(4.0E8),
    IBBT(9.0e-4),
    IBN(1.0),
    RSH(0.0),
    HDIF(0.5E-6),
    AVTO(1E-6),
    AKP(1E-6),
    AGAMMA(1E-6),
    AF(1.0),
    KF(0.0),
    xd_n(1.0),
    xd_js(1.0E-09),
    xd_jsw(1.0E-12),
    xd_jswg(1.0E-12),
    xd_mj(0.900),
    xd_mjsw(0.700),
    xd_mjswg(0.700),
    xd_pb(0.800),
    xd_pbsw(0.600),
    xd_pbswg(0.600),
    xd_cj(1.0E-09),
    xd_cjsw(1.0E-12),
    xd_cjswg(1.0E-12),
    xd_gmin(0.0),
    xd_xjbv(0.0),
    xd_bv(10.0),
    xd_njts(1.0),
    xd_njtssw(1.0),
    xd_njtsswg(1.0),
    xd_vts(0.0),
    xd_vtssw(0.0),
    xd_vtsswg(0.0),
    tp_xti(3.0),
    tp_cj(0.0),
    tp_cjsw(0.0),
    tp_cjswg(0.0),
    tp_pb(0.0),
    tp_pbsw(0.0),
    tp_pbswg(0.0),
    tp_njts(0.0),
    tp_njtssw(0.0),
    tp_njtsswg(0.0),
    LMIN(0),
    LMAX(100),
    WMIN(0),
    WMAX(100)
{
  // Set params to constant default values (from parTable):
  setDefaultParams();

  // Set params according to .model line and constant defaults from metadata:
  setModParams(model_block.params);

  if (!given("XYCEADMSMODTEMP"))
    admsModTemp=getDeviceOptions().temp.getImmutableValue<double>();

  // Calculate any parameters specified as expressions:

  updateDependentParameters();

  // calculate dependent (ie computed) params and check for errors:
  processParams();
}

//-----------------------------------------------------------------------------
// Function      : Model::~Model
// Purpose       : destructor
// Special Notes :
// Scope         : public
// Creator       :
// Creation Date :
//-----------------------------------------------------------------------------
Model::~Model()
{
  std::vector<Instance*>::iterator iterI;
  std::vector<Instance*>::iterator firstI = instanceContainer.begin ();
  std::vector<Instance*>::iterator lastI  = instanceContainer.end ();

  // loop over instances:
  for (iterI = firstI; iterI != lastI; ++iterI)
  {
    delete (*iterI);
  }
}

//-----------------------------------------------------------------------------
// Function      : Model::printOutInstances
// Purpose       : debugging tool.
// Special Notes :
// Scope         : public
// Creator       :
// Creation Date :
//-----------------------------------------------------------------------------
std::ostream &Model::printOutInstances(std::ostream &os) const
{
  std::vector<Instance*>::const_iterator iter;
  std::vector<Instance*>::const_iterator first = instanceContainer.begin();
  std::vector<Instance*>::const_iterator last  = instanceContainer.end();

  int i;
  os << std::endl;
  os << "    name     model name  Parameters" << std::endl;
  for (i=0, iter=first; iter!=last; ++iter, ++i)
  {
    os << "  " << i << ": " << (*iter)->getName() << "      ";
    os << getName();

    os << std::endl;
      os << "L  =  " << (*iter)->L << std::endl;
      os << "W  =  " << (*iter)->W << std::endl;
      os << "M  =  " << (*iter)->M << std::endl;
      os << "NS  =  " << (*iter)->NS << std::endl;
      os << "AS  =  " << (*iter)->AS << std::endl;
      os << "AD  =  " << (*iter)->AD << std::endl;
      os << "PS  =  " << (*iter)->PS << std::endl;
      os << "PD  =  " << (*iter)->PD << std::endl;
    os << std::endl;
  }

  os << std::endl;

  return os;
}

//-----------------------------------------------------------------------------
// Function      : Model::forEachInstance
// Purpose       :
// Special Notes :
// Scope         : public
// Creator       : David Baur
// Creation Date : 2/4/2014
//-----------------------------------------------------------------------------
/// Apply a device instance "op" to all instances associated with this
/// model
///
/// @param[in] op Operator to apply to all instances.
///
///
void Model::forEachInstance(DeviceInstanceOp &op) const
{
  for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
    op(*it);
}

Device *Traits::factory(const Configuration &configuration, const FactoryBlock &factory_block)
{
  return new DeviceMaster<Traits>(configuration, factory_block, factory_block.solverState_, factory_block.deviceOptions_);
}

void
registerDevice(const DeviceCountMap& deviceMap, const std::set<int>& levelSet)
{
if (deviceMap.empty() ||
((deviceMap.find("M") != deviceMap.end() && (levelSet.find(260)!=levelSet.end()))))
{
MOSFET1::registerDevice();
  Config<Traits>::addConfiguration()
    .registerDevice("m", 260)
    .registerModelType("nmos", 260)
    .registerModelType("pmos", 260);
}
}


#ifdef Xyce_ADMS_SENSITIVITIES
//-----------------------------------------------------------------------------
// Function      : evaluateInitialInstance
// Purpose       : Evaluate the statements in the initial_instance block
// Special Notes : specific for sensitivity use
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
void evaluateInitialInstance(
instanceSensStruct & instanceStruct,
modelSensStruct & modelStruct,
 double admsTemperature, double adms_vt_nom, double ADMSgmin_arg, const Instance & theInstance)
{
}



//-----------------------------------------------------------------------------
// Function      : evaluateInitialModel
// Purpose       : Evaluate the statements in the initial_model block
// Special Notes : specific for sensitivity use
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
void evaluateInitialModel(
modelSensStruct & modelStruct,
 double admsTemperature, double ADMSgmin_arg, const Instance & theInstance)
{
}



//-----------------------------------------------------------------------------
// Function      : evaluateModelEquations
// Purpose       : Evaluate the main module block.  Similar to
//                 updateIntermediateVars, but takes all instance and model
//                 parameters and variables as arguments instead of using
//                 the ones stored in the objects.
// Special Notes : specific for sensitivity use
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
void evaluateModelEquations(
std::vector <double> & probeVars,
// probe constants
const int admsProbeID_V_d_b,
const int admsProbeID_V_s_b,
const int admsProbeID_V_g_b,
// node constants
const int admsNodeID_d,
const int admsNodeID_g,
const int admsNodeID_s,
const int admsNodeID_b,
instanceSensStruct & instanceStruct,
modelSensStruct & modelStruct,
// basic variables
 double admsTemperature, double adms_vt_nom, double ADMSgmin_arg, std::vector <double> & d_staticContributions_dX, std::vector <double> & d_dynamicContributions_dX, const Instance & theInstance)
{

  // Local variables
  double qjs=0.0;
double d_qjs_dX=0.0;
  double csswg_s=0.0;
double d_csswg_s_dX=0.0;
  double cssw_s=0.0;
double d_cssw_s_dX=0.0;
  double csb_s=0.0;
double d_csb_s_dX=0.0;
  double qjd=0.0;
double d_qjd_dX=0.0;
  double csswg_d=0.0;
double d_csswg_d_dX=0.0;
  double cssw_d=0.0;
double d_cssw_d_dX=0.0;
  double csb_d=0.0;
double d_csb_d_dX=0.0;
  double isb_tun=0.0;
double d_isb_tun_dX=0.0;
  double f_breakdown_s=0.0;
double d_f_breakdown_s_dX=0.0;
  double arg_s=0.0;
double d_arg_s_dX=0.0;
  double is_s=0.0;
double d_is_s_dX=0.0;
  double idb_tun=0.0;
double d_idb_tun_dX=0.0;
  double f_breakdown_d=0.0;
double d_f_breakdown_d_dX=0.0;
  double tmp0=0.0;
double d_tmp0_dX=0.0;
  double arg_d=0.0;
double d_arg_d_dX=0.0;
  double is_d=0.0;
double d_is_d_dX=0.0;
  double v_si_b=0.0;
double d_v_si_b_dX=0.0;
  double v_di_b=0.0;
double d_v_di_b_dX=0.0;
  double njtsswg_t=0.0;
double d_njtsswg_t_dX=0.0;
  double njtssw_t=0.0;
double d_njtssw_t_dX=0.0;
  double njts_t=0.0;
double d_njts_t_dX=0.0;
  double cjswg_t=0.0;
double d_cjswg_t_dX=0.0;
  double cjsw_t=0.0;
double d_cjsw_t_dX=0.0;
  double cj_t=0.0;
double d_cj_t_dX=0.0;
  double pbswg_t=0.0;
double d_pbswg_t_dX=0.0;
  double pbsw_t=0.0;
double d_pbsw_t_dX=0.0;
  double pb_t=0.0;
double d_pb_t_dX=0.0;
  double jswg_t=0.0;
double d_jswg_t_dX=0.0;
  double jsw_t=0.0;
double d_jsw_t_dX=0.0;
  double js_t=0.0;
double d_js_t_dX=0.0;
  double temp_arg=0.0;
double d_temp_arg_dX=0.0;
  double pd_i=0.0;
double d_pd_i_dX=0.0;
  double ad_i=0.0;
double d_ad_i_dX=0.0;
  double ps_i=0.0;
double d_ps_i_dX=0.0;
  double as_i=0.0;
double d_as_i_dX=0.0;
  double ddt_QS=0.0;
double d_ddt_QS_dX=0.0;
  double ddt_QD=0.0;
double d_ddt_QD_dX=0.0;
  double QG=0.0;
double d_QG_dX=0.0;
  double QB=0.0;
double d_QB_dX=0.0;
  double QI=0.0;
double d_QI_dX=0.0;
  double QS=0.0;
double d_QS_dX=0.0;
  double QD=0.0;
double d_QD_dX=0.0;
  double n_Vt_COX=0.0;
double d_n_Vt_COX_dX=0.0;
  double sqrt_PHI_VP2_2=0.0;
double d_sqrt_PHI_VP2_2_dX=0.0;
  double sir3=0.0;
double d_sir3_dX=0.0;
  double sif3=0.0;
double d_sif3_dX=0.0;
  double WLCox=0.0;
double d_WLCox_dX=0.0;
  double dIsub_factor=0.0;
double d_dIsub_factor_dX=0.0;
  double Isub=0.0;
double d_Isub_dX=0.0;
  double isub=0.0;
double d_isub_dX=0.0;
  double exp_ib=0.0;
double d_exp_ib_dX=0.0;
  double Lc_IBB_Vib=0.0;
double d_Lc_IBB_Vib_dX=0.0;
  double inv_Vib=0.0;
double d_inv_Vib_dX=0.0;
  double Vib=0.0;
double d_Vib_dX=0.0;
  double RDeff=0.0;
double d_RDeff_dX=0.0;
  double RSeff=0.0;
double d_RSeff_dX=0.0;
  double gmbs=0.0;
double d_gmbs_dX=0.0;
  double gm=0.0;
double d_gm_dX=0.0;
  double gms=0.0;
double d_gms_dX=0.0;
  double gds=0.0;
double d_gds_dX=0.0;
  double dn_dVG=0.0;
double d_dn_dVG_dX=0.0;
  double dn_dVS=0.0;
double d_dn_dVS_dX=0.0;
  double dn_dVD=0.0;
double d_dn_dVD_dX=0.0;
  double dbeta_dVG=0.0;
double d_dbeta_dVG_dX=0.0;
  double dbeta_dVS=0.0;
double d_dbeta_dVS_dX=0.0;
  double dbeta_dVD=0.0;
double d_dbeta_dVD_dX=0.0;
  double dVPprime_dVG=0.0;
double d_dVPprime_dVG_dX=0.0;
  double dVPprime_dVS=0.0;
double d_dVPprime_dVS_dX=0.0;
  double dVPprime_dVD=0.0;
double d_dVPprime_dVD_dX=0.0;
  double dQB_dVG=0.0;
double d_dQB_dVG_dX=0.0;
  double dQB_dVS=0.0;
double d_dQB_dVS_dX=0.0;
  double dQB_dVD=0.0;
double d_dQB_dVD_dX=0.0;
  double dQI_dVG=0.0;
double d_dQI_dVG_dX=0.0;
  double dQI_dVS=0.0;
double d_dQI_dVS_dX=0.0;
  double dQI_dVD=0.0;
double d_dQI_dVD_dX=0.0;
  double dir_dVG=0.0;
double d_dir_dVG_dX=0.0;
  double dir_dVS=0.0;
double d_dir_dVS_dX=0.0;
  double dir_dVD=0.0;
double d_dir_dVD_dX=0.0;
  double dLeq_dVG=0.0;
double d_dLeq_dVG_dX=0.0;
  double dLeq_dVS=0.0;
double d_dLeq_dVS_dX=0.0;
  double dLeq_dVD=0.0;
double d_dLeq_dVD_dX=0.0;
  double ddeltaL_dVG=0.0;
double d_ddeltaL_dVG_dX=0.0;
  double ddeltaL_dVS=0.0;
double d_ddeltaL_dVS_dX=0.0;
  double ddeltaL_dVD=0.0;
double d_ddeltaL_dVD_dX=0.0;
  double dirprime_dVG=0.0;
double d_dirprime_dVG_dX=0.0;
  double dirprime_dVS=0.0;
double d_dirprime_dVS_dX=0.0;
  double dirprime_dVD=0.0;
double d_dirprime_dVD_dX=0.0;
  double dVDSSprime_dVG=0.0;
double d_dVDSSprime_dVG_dX=0.0;
  double dVDSSprime_dVS=0.0;
double d_dVDSSprime_dVS_dX=0.0;
  double dVDSSprime_dVD=0.0;
double d_dVDSSprime_dVD_dX=0.0;
  double dVip_dVG=0.0;
double d_dVip_dVG_dX=0.0;
  double dVip_dVS=0.0;
double d_dVip_dVS_dX=0.0;
  double dVip_dVD=0.0;
double d_dVip_dVD_dX=0.0;
  double ddeltaV_dVG=0.0;
double d_ddeltaV_dVG_dX=0.0;
  double ddeltaV_dVS=0.0;
double d_ddeltaV_dVS_dX=0.0;
  double ddeltaV_dVD=0.0;
double d_ddeltaV_dVD_dX=0.0;
  double dVDSS_dVG=0.0;
double d_dVDSS_dVG_dX=0.0;
  double dVDSS_dVS=0.0;
double d_dVDSS_dVS_dX=0.0;
  double dVDSS_dVD=0.0;
double d_dVDSS_dVD_dX=0.0;
  double dif_dVG=0.0;
double d_dif_dVG_dX=0.0;
  double dif_dVS=0.0;
double d_dif_dVS_dX=0.0;
  double dif_dVD=0.0;
double d_dif_dVD_dX=0.0;
  double dVP_dVG=0.0;
double d_dVP_dVG_dX=0.0;
  double dVP_dVS=0.0;
double d_dVP_dVS_dX=0.0;
  double dVP_dVD=0.0;
double d_dVP_dVD_dX=0.0;
  double tmp3=0.0;
double d_tmp3_dX=0.0;
  double dGAMMAprime_dVG=0.0;
double d_dGAMMAprime_dVG_dX=0.0;
  double dGAMMAprime_dVS=0.0;
double d_dGAMMAprime_dVS_dX=0.0;
  double dGAMMAprime_dVD=0.0;
double d_dGAMMAprime_dVD_dX=0.0;
  double Gn=0.0;
double d_Gn_dX=0.0;
  double Vdsat=0.0;
double d_Vdsat_dX=0.0;
  double Von=0.0;
double d_Von_dX=0.0;
  double Id=0.0;
double d_Id_dX=0.0;
  double Ispec=0.0;
double d_Ispec_dX=0.0;
  double if_ir=0.0;
double d_if_ir_dX=0.0;
  double n=0.0;
double d_n_dX=0.0;
  double sqrt_PHI_VP=0.0;
double d_sqrt_PHI_VP_dX=0.0;
  double beta=0.0;
double d_beta_dX=0.0;
  double T0_GAMMA_1=0.0;
double d_T0_GAMMA_1_dX=0.0;
  double E0_Q_1=0.0;
double d_E0_Q_1_dX=0.0;
  double qb=0.0;
double d_qb_dX=0.0;
  double qi=0.0;
double d_qi_dX=0.0;
  double n_1_n=0.0;
double d_n_1_n_dX=0.0;
  double n_1=0.0;
double d_n_1_dX=0.0;
  double sqrt_PHI_VP_2=0.0;
double d_sqrt_PHI_VP_2_dX=0.0;
  double VP_PHI_eps=0.0;
double d_VP_PHI_eps_dX=0.0;
  double sif_sir_2=0.0;
double d_sif_sir_2_dX=0.0;
  double sir=0.0;
double d_sir_dX=0.0;
  double sif=0.0;
double d_sif_dX=0.0;
  double sir2=0.0;
double d_sir2_dX=0.0;
  double sif2=0.0;
double d_sif2_dX=0.0;
  double dir_dv=0.0;
double d_dir_dv_dX=0.0;
  double sqrt_ir=0.0;
double d_sqrt_ir_dX=0.0;
  double ir=0.0;
double d_ir_dX=0.0;
  double Leq=0.0;
double d_Leq_dX=0.0;
  double sqrt_Lprime_Lmin=0.0;
double d_sqrt_Lprime_Lmin_dX=0.0;
  double Lmin=0.0;
double d_Lmin_dX=0.0;
  double Lprime=0.0;
double d_Lprime_dX=0.0;
  double deltaL=0.0;
double d_deltaL_dX=0.0;
  double dirprime_dv=0.0;
double d_dirprime_dv_dX=0.0;
  double sqrt_irprime=0.0;
double d_sqrt_irprime_dX=0.0;
  double irprime=0.0;
double d_irprime_dX=0.0;
  double sqrt_Vds_VDSSprime_deltaV=0.0;
double d_sqrt_Vds_VDSSprime_deltaV_dX=0.0;
  double sqrt_VDSSprime_deltaV=0.0;
double d_sqrt_VDSSprime_deltaV_dX=0.0;
  double Vdsprime=0.0;
double d_Vdsprime_dX=0.0;
  double VDSSprime=0.0;
double d_VDSSprime_dX=0.0;
  double VDSSprime_sqrt=0.0;
double d_VDSSprime_sqrt_dX=0.0;
  double Vip=0.0;
double d_Vip_dX=0.0;
  double sqrt_Vds_VDSS_deltaV=0.0;
double d_sqrt_Vds_VDSS_deltaV_dX=0.0;
  double sqrt_VDSS_deltaV=0.0;
double d_sqrt_VDSS_deltaV_dX=0.0;
  double deltaV_2=0.0;
double d_deltaV_2_dX=0.0;
  double Vds=0.0;
double d_Vds_dX=0.0;
  double VDSS=0.0;
double d_VDSS_dX=0.0;
  double VDSS_sqrt=0.0;
double d_VDSS_sqrt_dX=0.0;
  double Vt_Vc=0.0;
double d_Vt_Vc_dX=0.0;
  double dif_dv=0.0;
double d_dif_dv_dX=0.0;
  double sqrt_if=0.0;
double d_sqrt_if_dX=0.0;
  double if_=0.0;
double d_if__dX=0.0;
  double yk=0.0;
double d_yk_dX=0.0;
  double zk=0.0;
double d_zk_dX=0.0;
  double z0=0.0;
double d_z0_dX=0.0;
  double VP=0.0;
double d_VP_dX=0.0;
  double big_sqrt_VP=0.0;
double d_big_sqrt_VP_dX=0.0;
  double GAMMAprime=0.0;
double d_GAMMAprime_dX=0.0;
  double sqrt_GAMMAstar=0.0;
double d_sqrt_GAMMAstar_dX=0.0;
  double GAMMAstar=0.0;
double d_GAMMAstar_dX=0.0;
  double sqrt_PHI_VP0=0.0;
double d_sqrt_PHI_VP0_dX=0.0;
  double VP0=0.0;
double d_VP0_dX=0.0;
  double big_sqrt_VP0=0.0;
double d_big_sqrt_VP0_dX=0.0;
  double LETA_L=0.0;
double d_LETA_L_dX=0.0;
  double WETA_W=0.0;
double d_WETA_W_dX=0.0;
  double sqrt_PHI_VD=0.0;
double d_sqrt_PHI_VD_dX=0.0;
  double sqrt_PHI_VD_Vt=0.0;
double d_sqrt_PHI_VD_Vt_dX=0.0;
  double PHI_VD=0.0;
double d_PHI_VD_dX=0.0;
  double sqrt_PHI_VS=0.0;
double d_sqrt_PHI_VS_dX=0.0;
  double sqrt_PHI_VS_Vt=0.0;
double d_sqrt_PHI_VS_Vt_dX=0.0;
  double PHI_VS=0.0;
double d_PHI_VS_dX=0.0;
  double VGprime=0.0;
double d_VGprime_dX=0.0;
  double sqrt_VGstar=0.0;
double d_sqrt_VGstar_dX=0.0;
  double VGstar=0.0;
double d_VGstar_dX=0.0;
  double T1=0.0;
double d_T1_dX=0.0;
  int Mode=0.0;
  double VD=0.0;
double d_VD_dX=0.0;
  double VS=0.0;
double d_VS_dX=0.0;
  double VG=0.0;
double d_VG_dX=0.0;
  double deltaVFB=0.0;
double d_deltaVFB_dX=0.0;
  double vL=0.0;
double d_vL_dX=0.0;
  double GAMMA_sqrt_PHI=0.0;
double d_GAMMA_sqrt_PHI_dX=0.0;
  double GAMMA_S=0.0;
double d_GAMMA_S_dX=0.0;
  double KP_Weff=0.0;
double d_KP_Weff_dX=0.0;
  double VTO_S=0.0;
double d_VTO_S_dX=0.0;
  double AWL=0.0;
double d_AWL_dX=0.0;
  double log_Vc_Vt=0.0;
double d_log_Vc_Vt_dX=0.0;
  double Vc=0.0;
double d_Vc_dX=0.0;
  double Weff=0.0;
double d_Weff_dX=0.0;
  double Leff=0.0;
double d_Leff_dX=0.0;
  double IBA_IBB=0.0;
double d_IBA_IBB_dX=0.0;
  double Lc_IBB=0.0;
double d_Lc_IBB_dX=0.0;
  double Lc_UCRIT=0.0;
double d_Lc_UCRIT_dX=0.0;
  double inv_UCRIT=0.0;
double d_inv_UCRIT_dX=0.0;
  double sqrt_PHI=0.0;
double d_sqrt_PHI_dX=0.0;
  double tmp2=0.0;
double d_tmp2_dX=0.0;
  double tmp1=0.0;
double d_tmp1_dX=0.0;
  double PHI_T=0.0;
double d_PHI_T_dX=0.0;
  double IBB_T=0.0;
double d_IBB_T_dX=0.0;
  double UCRIT_T=0.0;
double d_UCRIT_T_dX=0.0;
  double KP_T=0.0;
double d_KP_T_dX=0.0;
  double VTO_T=0.0;
double d_VTO_T_dX=0.0;
  double ratioT=0.0;
double d_ratioT_dX=0.0;
  double deltaT=0.0;
double d_deltaT_dX=0.0;
  double refEg=0.0;
double d_refEg_dX=0.0;
  double Eg=0.0;
double d_Eg_dX=0.0;
  double Vt_Vt_16=0.0;
double d_Vt_Vt_16_dX=0.0;
  double Vt_Vt_2=0.0;
double d_Vt_Vt_2_dX=0.0;
  double Vt_Vt=0.0;
double d_Vt_Vt_dX=0.0;
  double Vt_4=0.0;
double d_Vt_4_dX=0.0;
  double Vt_2=0.0;
double d_Vt_2_dX=0.0;
  double inv_Vt=0.0;
double d_inv_Vt_dX=0.0;
  double Vt_01=0.0;
double d_Vt_01_dX=0.0;
  double Vt=0.0;
double d_Vt_dX=0.0;
  double Tnom=0.0;
double d_Tnom_dX=0.0;
  double T=0.0;
double d_T_dX=0.0;
  double eta_qi=0.0;
double d_eta_qi_dX=0.0;
  double V0=0.0;
double d_V0_dX=0.0;
  double T0=0.0;
double d_T0_dX=0.0;
  double IBN_2=0.0;
double d_IBN_2_dX=0.0;
  double eps_COX_L=0.0;
double d_eps_COX_L_dX=0.0;
  double eps_COX_W=0.0;
double d_eps_COX_W_dX=0.0;
  double Lc_LAMBDA=0.0;
double d_Lc_LAMBDA_dX=0.0;
  double Lc=0.0;
double d_Lc_dX=0.0;
  double eps_COX=0.0;
double d_eps_COX_dX=0.0;
  double sqrt_VP_Vt=0.0;
double d_sqrt_VP_Vt_dX=0.0;
  double VPprime=0.0;
double d_VPprime_dX=0.0;
  double THETA_VP_1=0.0;
double d_THETA_VP_1_dX=0.0;
  double Ibd=0.0;
double d_Ibd_dX=0.0;
  double epssil=0.0;
  double EPSOX=0.0;


  // -- code converted from analog/code block
EPSOX = (3.9*8.85418792394420013968e-12);
epssil = (11.7*8.85418792394420013968e-12);
d_Ibd_dX = 0.0;
Ibd = 0.0;
d_THETA_VP_1_dX = 0.0;
THETA_VP_1 = 0.0;
d_VPprime_dX = 0.0;
VPprime = 0.0;
d_sqrt_VP_Vt_dX = 0.0;
sqrt_VP_Vt = 0.0;
d_eps_COX_dX = (-epssil*modelStruct.d_modelPar_COX_dX/modelStruct.modelPar_COX/modelStruct.modelPar_COX);
eps_COX = (epssil/modelStruct.modelPar_COX);
{
double value_sqrt_0 = sqrt((eps_COX*modelStruct.modelPar_XJ));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_Lc_dX = deriv_sqrt_0_d0*((eps_COX*modelStruct.d_modelPar_XJ_dX+d_eps_COX_dX*modelStruct.modelPar_XJ));
Lc = value_sqrt_0;
}
d_Lc_LAMBDA_dX = (Lc*modelStruct.d_modelPar_LAMBDA_dX+d_Lc_dX*modelStruct.modelPar_LAMBDA);
Lc_LAMBDA = (Lc*modelStruct.modelPar_LAMBDA);
d_eps_COX_W_dX = ((3.0*eps_COX)*modelStruct.d_modelPar_WETA_dX+3.0*d_eps_COX_dX*modelStruct.modelPar_WETA);
eps_COX_W = ((3.0*eps_COX)*modelStruct.modelPar_WETA);
d_eps_COX_L_dX = (eps_COX*modelStruct.d_modelPar_LETA_dX+d_eps_COX_dX*modelStruct.modelPar_LETA);
eps_COX_L = (eps_COX*modelStruct.modelPar_LETA);
d_IBN_2_dX = (modelStruct.d_modelPar_IBN_dX+modelStruct.d_modelPar_IBN_dX);
IBN_2 = (modelStruct.modelPar_IBN+modelStruct.modelPar_IBN);
d_T0_dX = (((epssil*modelStruct.modelPar_E0)*modelStruct.d_modelPar_COX_dX-modelStruct.modelPar_COX*epssil*modelStruct.d_modelPar_E0_dX)/(epssil*modelStruct.modelPar_E0)/(epssil*modelStruct.modelPar_E0));
T0 = (modelStruct.modelPar_COX/(epssil*modelStruct.modelPar_E0));
d_V0_dX = ((modelStruct.modelPar_COX*(modelStruct.d_modelPar_Q0_dX+modelStruct.d_modelPar_Q0_dX)-(modelStruct.modelPar_Q0+modelStruct.modelPar_Q0)*modelStruct.d_modelPar_COX_dX)/modelStruct.modelPar_COX/modelStruct.modelPar_COX);
V0 = ((modelStruct.modelPar_Q0+modelStruct.modelPar_Q0)/modelStruct.modelPar_COX);
d_eta_qi_dX = 0.0;
eta_qi = ((modelStruct.modelPar_TYPE>0)?0.5:0.3333333333333);
if ((modelStruct.modelPar_TEMP==1.0e21))
{
d_T_dX = modelStruct.d_modelPar_Trise_dX;
T = (admsTemperature+modelStruct.modelPar_Trise);
}
else
{
d_T_dX = modelStruct.d_modelPar_TEMP_dX;
T = (modelStruct.modelPar_TEMP+273.15);
}
if ((modelStruct.modelPar_TNOM==1.0e21))
{
d_Tnom_dX = 0.0;
Tnom = (25+273.15);
}
else
{
d_Tnom_dX = modelStruct.d_modelPar_TNOM_dX;
Tnom = (modelStruct.modelPar_TNOM+273.15);
}
d_Vt_dX = 0.0;
Vt = adms_vt(T);
d_Vt_01_dX = 0.1*d_Vt_dX;
Vt_01 = (0.1*Vt);
d_inv_Vt_dX = (-d_Vt_dX/Vt/Vt);
inv_Vt = (1.0/Vt);
d_Vt_2_dX = (d_Vt_dX+d_Vt_dX);
Vt_2 = (Vt+Vt);
d_Vt_4_dX = (d_Vt_2_dX+d_Vt_2_dX);
Vt_4 = (Vt_2+Vt_2);
d_Vt_Vt_dX = (Vt*d_Vt_dX+d_Vt_dX*Vt);
Vt_Vt = (Vt*Vt);
d_Vt_Vt_2_dX = (d_Vt_Vt_dX+d_Vt_Vt_dX);
Vt_Vt_2 = (Vt_Vt+Vt_Vt);
d_Vt_Vt_16_dX = 16.0*d_Vt_Vt_dX;
Vt_Vt_16 = (16.0*Vt_Vt);
d_Eg_dX = (-(((T+1108.0)*((7.02e-4*T)*d_T_dX+7.02e-4*d_T_dX*T)-((7.02e-4*T)*T)*d_T_dX)/(T+1108.0)/(T+1108.0)));
Eg = (1.16-(((7.02e-4*T)*T)/(T+1108.0)));
d_refEg_dX = (-(((Tnom+1108.0)*((7.02e-4*Tnom)*d_Tnom_dX+7.02e-4*d_Tnom_dX*Tnom)-((7.02e-4*Tnom)*Tnom)*d_Tnom_dX)/(Tnom+1108.0)/(Tnom+1108.0)));
refEg = (1.16-(((7.02e-4*Tnom)*Tnom)/(Tnom+1108.0)));
d_deltaT_dX = (d_T_dX-d_Tnom_dX);
deltaT = (T-Tnom);
d_ratioT_dX = ((Tnom*d_T_dX-T*d_Tnom_dX)/Tnom/Tnom);
ratioT = (T/Tnom);
d_VTO_T_dX = (modelStruct.d_modelPar_VTO_dX-(modelStruct.modelPar_TCV*d_deltaT_dX+modelStruct.d_modelPar_TCV_dX*deltaT));
VTO_T = (modelStruct.modelPar_VTO-(modelStruct.modelPar_TCV*deltaT));
{
double value_pow_0 = pow(ratioT,modelStruct.modelPar_BEX);
double  deriv_pow_0_d0 = ((ratioT == 0.0)?0.0:(value_pow_0*modelStruct.modelPar_BEX/ratioT));
double  deriv_pow_0_d1 = (ratioT == 0.0)?0.0:(log(ratioT)*value_pow_0);
d_KP_T_dX = (modelStruct.modelPar_KP*((deriv_pow_0_d0*(d_ratioT_dX))+(deriv_pow_0_d1*(modelStruct.d_modelPar_BEX_dX)))+modelStruct.d_modelPar_KP_dX*value_pow_0);
KP_T = (modelStruct.modelPar_KP*value_pow_0);
}
{
double value_pow_0 = pow(ratioT,modelStruct.modelPar_UCEX);
double  deriv_pow_0_d0 = ((ratioT == 0.0)?0.0:(value_pow_0*modelStruct.modelPar_UCEX/ratioT));
double  deriv_pow_0_d1 = (ratioT == 0.0)?0.0:(log(ratioT)*value_pow_0);
d_UCRIT_T_dX = (modelStruct.modelPar_UCRIT*((deriv_pow_0_d0*(d_ratioT_dX))+(deriv_pow_0_d1*(modelStruct.d_modelPar_UCEX_dX)))+modelStruct.d_modelPar_UCRIT_dX*value_pow_0);
UCRIT_T = (modelStruct.modelPar_UCRIT*value_pow_0);
}
d_IBB_T_dX = (modelStruct.modelPar_IBB*(modelStruct.modelPar_IBBT*d_deltaT_dX+modelStruct.d_modelPar_IBBT_dX*deltaT)+modelStruct.d_modelPar_IBB_dX*(1.0+(modelStruct.modelPar_IBBT*deltaT)));
IBB_T = (modelStruct.modelPar_IBB*(1.0+(modelStruct.modelPar_IBBT*deltaT)));
{
double value_log_0 = log(ratioT);
double  deriv_log_0_d0 = (1.0/ratioT);
d_PHI_T_dX = ((((modelStruct.modelPar_PHI*d_ratioT_dX+modelStruct.d_modelPar_PHI_dX*ratioT)-((3.0*Vt)*deriv_log_0_d0*(d_ratioT_dX)+3.0*d_Vt_dX*value_log_0))-(refEg*d_ratioT_dX+d_refEg_dX*ratioT))+d_Eg_dX);
PHI_T = ((((modelStruct.modelPar_PHI*ratioT)-((3.0*Vt)*value_log_0))-(refEg*ratioT))+Eg);
}
d_tmp1_dX = 0.0;
tmp1 = 0.2;
d_tmp2_dX = (d_PHI_T_dX-d_tmp1_dX);
tmp2 = (PHI_T-tmp1);
{
double value_sqrt_0 = sqrt(((tmp2*tmp2)+(Vt*Vt)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_PHI_T_dX = (0.5*(d_tmp2_dX+deriv_sqrt_0_d0*(((tmp2*d_tmp2_dX+d_tmp2_dX*tmp2)+(Vt*d_Vt_dX+d_Vt_dX*Vt))))+d_tmp1_dX);
PHI_T = ((0.5*(tmp2+value_sqrt_0))+tmp1);
}
{
double value_sqrt_0 = sqrt(PHI_T);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_PHI_dX = deriv_sqrt_0_d0*(d_PHI_T_dX);
sqrt_PHI = value_sqrt_0;
}
d_inv_UCRIT_dX = (-d_UCRIT_T_dX/UCRIT_T/UCRIT_T);
inv_UCRIT = (1.0/UCRIT_T);
d_Lc_UCRIT_dX = (Lc*d_UCRIT_T_dX+d_Lc_dX*UCRIT_T);
Lc_UCRIT = (Lc*UCRIT_T);
d_Lc_IBB_dX = (Lc*d_IBB_T_dX+d_Lc_dX*IBB_T);
Lc_IBB = (Lc*IBB_T);
d_IBA_IBB_dX = ((IBB_T*modelStruct.d_modelPar_IBA_dX-modelStruct.modelPar_IBA*d_IBB_T_dX)/IBB_T/IBB_T);
IBA_IBB = (modelStruct.modelPar_IBA/IBB_T);
d_Leff_dX = (instanceStruct.d_instancePar_L_dX+modelStruct.d_modelPar_DL_dX);
Leff = (instanceStruct.instancePar_L+modelStruct.modelPar_DL);
d_Weff_dX = (instanceStruct.d_instancePar_W_dX+modelStruct.d_modelPar_DW_dX);
Weff = (instanceStruct.instancePar_W+modelStruct.modelPar_DW);
d_Vc_dX = (UCRIT_T*d_Leff_dX+d_UCRIT_T_dX*Leff);
Vc = (UCRIT_T*Leff);
{
double value_log_0 = log(((0.5*Vc)*inv_Vt));
double  deriv_log_0_d0 = (1.0/((0.5*Vc)*inv_Vt));
d_log_Vc_Vt_dX = (Vt*deriv_log_0_d0*(((0.5*Vc)*d_inv_Vt_dX+0.5*d_Vc_dX*inv_Vt))+d_Vt_dX*(value_log_0-0.6));
log_Vc_Vt = (Vt*(value_log_0-0.6));
}
{
double value_sqrt_0 = sqrt((Weff*Leff));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_AWL_dX = (-deriv_sqrt_0_d0*((Weff*d_Leff_dX+d_Weff_dX*Leff))/value_sqrt_0/value_sqrt_0);
AWL = (1.0/value_sqrt_0);
}
if ((modelStruct.modelPar_TYPE>0))
{
d_VTO_S_dX = ((modelStruct.modelPar_AVTO!=1e-6)?((AWL*modelStruct.d_modelPar_AVTO_dX+d_AWL_dX*(modelStruct.modelPar_AVTO-1e-6))+d_VTO_T_dX):d_VTO_T_dX);
VTO_S = ((modelStruct.modelPar_AVTO!=1e-6)?((AWL*(modelStruct.modelPar_AVTO-1e-6))+VTO_T):VTO_T);
}
else
{
d_VTO_S_dX = ((modelStruct.modelPar_AVTO!=1e-6)?((AWL*(-modelStruct.d_modelPar_AVTO_dX)+d_AWL_dX*(1e-6-modelStruct.modelPar_AVTO))-d_VTO_T_dX):(-d_VTO_T_dX));
VTO_S = ((modelStruct.modelPar_AVTO!=1e-6)?((AWL*(1e-6-modelStruct.modelPar_AVTO))-VTO_T):(-VTO_T));
}
d_KP_Weff_dX = (Weff*((modelStruct.modelPar_AKP!=1e-6)?(KP_T*((modelStruct.modelPar_AKP-1e-6)*d_AWL_dX+modelStruct.d_modelPar_AKP_dX*AWL)+d_KP_T_dX*(1+((modelStruct.modelPar_AKP-1e-6)*AWL))):d_KP_T_dX)+d_Weff_dX*((modelStruct.modelPar_AKP!=1e-6)?(KP_T*(1+((modelStruct.modelPar_AKP-1e-6)*AWL))):KP_T));
KP_Weff = (Weff*((modelStruct.modelPar_AKP!=1e-6)?(KP_T*(1+((modelStruct.modelPar_AKP-1e-6)*AWL))):KP_T));
d_GAMMA_S_dX = ((modelStruct.modelPar_AGAMMA!=1e-6)?(modelStruct.d_modelPar_GAMMA_dX+((modelStruct.modelPar_AGAMMA-1e-6)*d_AWL_dX+modelStruct.d_modelPar_AGAMMA_dX*AWL)):modelStruct.d_modelPar_GAMMA_dX);
GAMMA_S = ((modelStruct.modelPar_AGAMMA!=1e-6)?(modelStruct.modelPar_GAMMA+((modelStruct.modelPar_AGAMMA-1e-6)*AWL)):modelStruct.modelPar_GAMMA);
d_GAMMA_sqrt_PHI_dX = (GAMMA_S*d_sqrt_PHI_dX+d_GAMMA_S_dX*sqrt_PHI);
GAMMA_sqrt_PHI = (GAMMA_S*sqrt_PHI);
if ((V0==0.0))
{
d_deltaVFB_dX = 0.0;
deltaVFB = 0.0;
}
else
//Begin block VGprime_block
{
//Block-local variables for block VGprime_block
double sqv=0.0;
double d_sqv_dX=0.0;
//End of Block-local variables
d_vL_dX = 0.28*(((modelStruct.modelPar_LK*instanceStruct.instancePar_NS)*d_Leff_dX-Leff*(modelStruct.modelPar_LK*instanceStruct.d_instancePar_NS_dX+modelStruct.d_modelPar_LK_dX*instanceStruct.instancePar_NS))/(modelStruct.modelPar_LK*instanceStruct.instancePar_NS)/(modelStruct.modelPar_LK*instanceStruct.instancePar_NS));
vL = (0.28*((Leff/(modelStruct.modelPar_LK*instanceStruct.instancePar_NS))-0.1));
{
double value_sqrt_0 = sqrt(((vL*vL)+1.936e-3));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqv_dX = (-0.5*(d_vL_dX+deriv_sqrt_0_d0*((vL*d_vL_dX+d_vL_dX*vL)))/(1.0+(0.5*(vL+value_sqrt_0)))/(1.0+(0.5*(vL+value_sqrt_0))));
sqv = (1.0/(1.0+(0.5*(vL+value_sqrt_0))));
}
d_deltaVFB_dX = ((V0*sqv)*d_sqv_dX+(V0*d_sqv_dX+d_V0_dX*sqv)*sqv);
deltaVFB = ((V0*sqv)*sqv);
}
// End block VGprime_block
d_VG_dX = 0.0;
VG = (modelStruct.modelPar_TYPE*(probeVars[admsProbeID_V_g_b]));
d_VS_dX = 0.0;
VS = (modelStruct.modelPar_TYPE*(probeVars[admsProbeID_V_s_b]));
d_VD_dX = 0.0;
VD = (modelStruct.modelPar_TYPE*(probeVars[admsProbeID_V_d_b]));
if (((VD-VS)<0))
{
Mode = (-1);
d_T1_dX = d_VS_dX;
T1 = VS;
d_VS_dX = d_VD_dX;
VS = VD;
d_VD_dX = d_T1_dX;
VD = T1;
}
else
{
Mode = 1;
}
d_VGstar_dX = ((((d_VG_dX-d_VTO_S_dX)-d_deltaVFB_dX)+d_PHI_T_dX)+d_GAMMA_sqrt_PHI_dX);
VGstar = ((((VG-VTO_S)-deltaVFB)+PHI_T)+GAMMA_sqrt_PHI);
{
double value_sqrt_0 = sqrt(((VGstar*VGstar)+(2.0*Vt_Vt_16)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_VGstar_dX = deriv_sqrt_0_d0*(((VGstar*d_VGstar_dX+d_VGstar_dX*VGstar)+2.0*d_Vt_Vt_16_dX));
sqrt_VGstar = value_sqrt_0;
}
d_VGprime_dX = 0.5*(d_VGstar_dX+d_sqrt_VGstar_dX);
VGprime = (0.5*(VGstar+sqrt_VGstar));
d_PHI_VS_dX = (d_PHI_T_dX+d_VS_dX);
PHI_VS = (PHI_T+VS);
{
double value_sqrt_0 = sqrt(((PHI_VS*PHI_VS)+Vt_Vt_16));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_PHI_VS_Vt_dX = deriv_sqrt_0_d0*(((PHI_VS*d_PHI_VS_dX+d_PHI_VS_dX*PHI_VS)+d_Vt_Vt_16_dX));
sqrt_PHI_VS_Vt = value_sqrt_0;
}
{
double value_sqrt_0 = sqrt((0.5*(PHI_VS+sqrt_PHI_VS_Vt)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_PHI_VS_dX = deriv_sqrt_0_d0*(0.5*(d_PHI_VS_dX+d_sqrt_PHI_VS_Vt_dX));
sqrt_PHI_VS = value_sqrt_0;
}
d_PHI_VD_dX = (d_PHI_T_dX+d_VD_dX);
PHI_VD = (PHI_T+VD);
{
double value_sqrt_0 = sqrt(((PHI_VD*PHI_VD)+Vt_Vt_16));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_PHI_VD_Vt_dX = deriv_sqrt_0_d0*(((PHI_VD*d_PHI_VD_dX+d_PHI_VD_dX*PHI_VD)+d_Vt_Vt_16_dX));
sqrt_PHI_VD_Vt = value_sqrt_0;
}
{
double value_sqrt_0 = sqrt((0.5*(PHI_VD+sqrt_PHI_VD_Vt)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_PHI_VD_dX = deriv_sqrt_0_d0*(0.5*(d_PHI_VD_dX+d_sqrt_PHI_VD_Vt_dX));
sqrt_PHI_VD = value_sqrt_0;
}
d_WETA_W_dX = ((Weff*(eps_COX_W*instanceStruct.d_instancePar_M_dX+d_eps_COX_W_dX*instanceStruct.instancePar_M)-(eps_COX_W*instanceStruct.instancePar_M)*d_Weff_dX)/Weff/Weff);
WETA_W = ((eps_COX_W*instanceStruct.instancePar_M)/Weff);
d_LETA_L_dX = ((Leff*(eps_COX_L*instanceStruct.d_instancePar_NS_dX+d_eps_COX_L_dX*instanceStruct.instancePar_NS)-(eps_COX_L*instanceStruct.instancePar_NS)*d_Leff_dX)/Leff/Leff);
LETA_L = ((eps_COX_L*instanceStruct.instancePar_NS)/Leff);
{
double value_sqrt_0 = sqrt((VGprime+((0.25*GAMMA_S)*GAMMA_S)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_big_sqrt_VP0_dX = deriv_sqrt_0_d0*((d_VGprime_dX+((0.25*GAMMA_S)*d_GAMMA_S_dX+0.25*d_GAMMA_S_dX*GAMMA_S)));
big_sqrt_VP0 = value_sqrt_0;
}
d_VP0_dX = ((d_VGprime_dX-d_PHI_T_dX)-(GAMMA_S*(d_big_sqrt_VP0_dX-0.5*d_GAMMA_S_dX)+d_GAMMA_S_dX*(big_sqrt_VP0-(0.5*GAMMA_S))));
VP0 = ((VGprime-PHI_T)-(GAMMA_S*(big_sqrt_VP0-(0.5*GAMMA_S))));
{
double value_sqrt_0 = sqrt(((VP0+PHI_T)+Vt_01));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_PHI_VP0_dX = deriv_sqrt_0_d0*(((d_VP0_dX+d_PHI_T_dX)+d_Vt_01_dX));
sqrt_PHI_VP0 = value_sqrt_0;
}
d_GAMMAstar_dX = ((d_GAMMA_S_dX-(LETA_L*(d_sqrt_PHI_VS_dX+d_sqrt_PHI_VD_dX)+d_LETA_L_dX*(sqrt_PHI_VS+sqrt_PHI_VD)))+(WETA_W*d_sqrt_PHI_VP0_dX+d_WETA_W_dX*sqrt_PHI_VP0));
GAMMAstar = ((GAMMA_S-(LETA_L*(sqrt_PHI_VS+sqrt_PHI_VD)))+(WETA_W*sqrt_PHI_VP0));
{
double value_sqrt_0 = sqrt(((GAMMAstar*GAMMAstar)+Vt_01));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_GAMMAstar_dX = deriv_sqrt_0_d0*(((GAMMAstar*d_GAMMAstar_dX+d_GAMMAstar_dX*GAMMAstar)+d_Vt_01_dX));
sqrt_GAMMAstar = value_sqrt_0;
}
d_GAMMAprime_dX = 0.5*(d_GAMMAstar_dX+d_sqrt_GAMMAstar_dX);
GAMMAprime = (0.5*(GAMMAstar+sqrt_GAMMAstar));
{
double value_sqrt_0 = sqrt((VGprime+((0.25*GAMMAprime)*GAMMAprime)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_big_sqrt_VP_dX = deriv_sqrt_0_d0*((d_VGprime_dX+((0.25*GAMMAprime)*d_GAMMAprime_dX+0.25*d_GAMMAprime_dX*GAMMAprime)));
big_sqrt_VP = value_sqrt_0;
}
d_VP_dX = ((d_VGprime_dX-d_PHI_T_dX)-(GAMMAprime*(d_big_sqrt_VP_dX-0.5*d_GAMMAprime_dX)+d_GAMMAprime_dX*(big_sqrt_VP-(0.5*GAMMAprime))));
VP = ((VGprime-PHI_T)-(GAMMAprime*(big_sqrt_VP-(0.5*GAMMAprime))));
d_tmp1_dX = ((VP-VS)*d_inv_Vt_dX+(d_VP_dX-d_VS_dX)*inv_Vt);
tmp1 = ((VP-VS)*inv_Vt);
if ((tmp1>(-0.35)))
{
{
double value_log_0 = log((tmp1+1.6));
double  deriv_log_0_d0 = (1.0/(tmp1+1.6));
d_z0_dX = (-2.0*(d_tmp1_dX-deriv_log_0_d0*(d_tmp1_dX))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
z0 = (2.0/((1.3+tmp1)-value_log_0));
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);
d_zk_dX = ((((1.0+tmp1)+value_log_0)*d_z0_dX-(2.0+z0)*(d_tmp1_dX+deriv_log_0_d0*(d_z0_dX)))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);
d_yk_dX = (((2.0+zk)*(d_tmp1_dX+deriv_log_0_d0*(d_zk_dX))-((1.0+tmp1)+value_log_0)*d_zk_dX)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-15.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;
d_z0_dX = deriv_exp_0_d0*((-d_tmp1_dX));
z0 = (1.55+value_exp_0);
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);
d_zk_dX = ((((1.0+tmp1)+value_log_0)*d_z0_dX-(2.0+z0)*(d_tmp1_dX+deriv_log_0_d0*(d_z0_dX)))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);
d_yk_dX = (((2.0+zk)*(d_tmp1_dX+deriv_log_0_d0*(d_zk_dX))-((1.0+tmp1)+value_log_0)*d_zk_dX)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-23.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;
d_yk_dX = (-deriv_exp_0_d0*((-d_tmp1_dX))/(2.0+value_exp_0)/(2.0+value_exp_0));
yk = (1.0/(2.0+value_exp_0));
}
}
else
{
{
double value_exp_0 = exp(tmp1);
double  deriv_exp_0_d0 = value_exp_0;
d_yk_dX = deriv_exp_0_d0*(d_tmp1_dX);
yk = (value_exp_0+1E-64);
}
}
}
}
d_if__dX = (yk*d_yk_dX+d_yk_dX*(1.0+yk));
if_ = (yk*(1.0+yk));
{
double value_sqrt_0 = sqrt(if_);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_if_dX = deriv_sqrt_0_d0*(d_if__dX);
sqrt_if = value_sqrt_0;
}
d_dif_dv_dX = d_yk_dX;
dif_dv = yk;
d_Vt_Vc_dX = ((Vc*d_Vt_dX-Vt*d_Vc_dX)/Vc/Vc);
Vt_Vc = (Vt/Vc);
{
double value_sqrt_0 = sqrt((0.25+(sqrt_if*Vt_Vc)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_VDSS_sqrt_dX = deriv_sqrt_0_d0*((sqrt_if*d_Vt_Vc_dX+d_sqrt_if_dX*Vt_Vc));
VDSS_sqrt = value_sqrt_0;
}
d_VDSS_dX = (Vc*d_VDSS_sqrt_dX+d_Vc_dX*(VDSS_sqrt-0.5));
VDSS = (Vc*(VDSS_sqrt-0.5));
d_Vds_dX = 0.5*(d_VD_dX-d_VS_dX);
Vds = (0.5*(VD-VS));
d_deltaV_2_dX = (Vt_Vt_16*(modelStruct.modelPar_LAMBDA*(d_sqrt_if_dX-(VDSS*d_inv_Vt_dX+d_VDSS_dX*inv_Vt))+modelStruct.d_modelPar_LAMBDA_dX*(sqrt_if-(VDSS*inv_Vt)))+d_Vt_Vt_16_dX*((modelStruct.modelPar_LAMBDA*(sqrt_if-(VDSS*inv_Vt)))+15.625e-3));
deltaV_2 = (Vt_Vt_16*((modelStruct.modelPar_LAMBDA*(sqrt_if-(VDSS*inv_Vt)))+15.625e-3));
{
double value_sqrt_0 = sqrt(((VDSS*VDSS)+deltaV_2));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_VDSS_deltaV_dX = deriv_sqrt_0_d0*(((VDSS*d_VDSS_dX+d_VDSS_dX*VDSS)+d_deltaV_2_dX));
sqrt_VDSS_deltaV = value_sqrt_0;
}
{
double value_sqrt_0 = sqrt((((Vds-VDSS)*(Vds-VDSS))+deltaV_2));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_Vds_VDSS_deltaV_dX = deriv_sqrt_0_d0*((((Vds-VDSS)*(d_Vds_dX-d_VDSS_dX)+(d_Vds_dX-d_VDSS_dX)*(Vds-VDSS))+d_deltaV_2_dX));
sqrt_Vds_VDSS_deltaV = value_sqrt_0;
}
d_Vip_dX = (d_sqrt_VDSS_deltaV_dX-d_sqrt_Vds_VDSS_deltaV_dX);
Vip = (sqrt_VDSS_deltaV-sqrt_Vds_VDSS_deltaV);
{
double value_log_0 = log(if_);
double value_sqrt_1 = sqrt((0.25+((sqrt_if-(0.75*value_log_0))*Vt_Vc)));
double  deriv_log_0_d0 = (1.0/if_);
double  deriv_sqrt_1_d0 = (0.5/value_sqrt_1);
d_VDSSprime_sqrt_dX = deriv_sqrt_1_d0*(((sqrt_if-(0.75*value_log_0))*d_Vt_Vc_dX+(d_sqrt_if_dX-0.75*deriv_log_0_d0*(d_if__dX))*Vt_Vc));
VDSSprime_sqrt = value_sqrt_1;
}
d_VDSSprime_dX = ((Vc*d_VDSSprime_sqrt_dX+d_Vc_dX*(VDSSprime_sqrt-0.5))+d_log_Vc_Vt_dX);
VDSSprime = ((Vc*(VDSSprime_sqrt-0.5))+log_Vc_Vt);
d_Vdsprime_dX = (d_Vds_dX-d_VDSSprime_dX);
Vdsprime = (Vds-VDSSprime);
{
double value_sqrt_0 = sqrt(((VDSSprime*VDSSprime)+deltaV_2));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_VDSSprime_deltaV_dX = deriv_sqrt_0_d0*(((VDSSprime*d_VDSSprime_dX+d_VDSSprime_dX*VDSSprime)+d_deltaV_2_dX));
sqrt_VDSSprime_deltaV = value_sqrt_0;
}
{
double value_sqrt_0 = sqrt(((Vdsprime*Vdsprime)+deltaV_2));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_Vds_VDSSprime_deltaV_dX = deriv_sqrt_0_d0*(((Vdsprime*d_Vdsprime_dX+d_Vdsprime_dX*Vdsprime)+d_deltaV_2_dX));
sqrt_Vds_VDSSprime_deltaV = value_sqrt_0;
}
d_tmp1_dX = (((((VP-Vds)-VS)-sqrt_VDSSprime_deltaV)+sqrt_Vds_VDSSprime_deltaV)*d_inv_Vt_dX+((((d_VP_dX-d_Vds_dX)-d_VS_dX)-d_sqrt_VDSSprime_deltaV_dX)+d_sqrt_Vds_VDSSprime_deltaV_dX)*inv_Vt);
tmp1 = (((((VP-Vds)-VS)-sqrt_VDSSprime_deltaV)+sqrt_Vds_VDSSprime_deltaV)*inv_Vt);
if ((tmp1>(-0.35)))
{
{
double value_log_0 = log((tmp1+1.6));
double  deriv_log_0_d0 = (1.0/(tmp1+1.6));
d_z0_dX = (-2.0*(d_tmp1_dX-deriv_log_0_d0*(d_tmp1_dX))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
z0 = (2.0/((1.3+tmp1)-value_log_0));
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);
d_zk_dX = ((((1.0+tmp1)+value_log_0)*d_z0_dX-(2.0+z0)*(d_tmp1_dX+deriv_log_0_d0*(d_z0_dX)))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);
d_yk_dX = (((2.0+zk)*(d_tmp1_dX+deriv_log_0_d0*(d_zk_dX))-((1.0+tmp1)+value_log_0)*d_zk_dX)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-15.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;
d_z0_dX = deriv_exp_0_d0*((-d_tmp1_dX));
z0 = (1.55+value_exp_0);
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);
d_zk_dX = ((((1.0+tmp1)+value_log_0)*d_z0_dX-(2.0+z0)*(d_tmp1_dX+deriv_log_0_d0*(d_z0_dX)))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);
d_yk_dX = (((2.0+zk)*(d_tmp1_dX+deriv_log_0_d0*(d_zk_dX))-((1.0+tmp1)+value_log_0)*d_zk_dX)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-23.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;
d_yk_dX = (-deriv_exp_0_d0*((-d_tmp1_dX))/(2.0+value_exp_0)/(2.0+value_exp_0));
yk = (1.0/(2.0+value_exp_0));
}
}
else
{
{
double value_exp_0 = exp(tmp1);
double  deriv_exp_0_d0 = value_exp_0;
d_yk_dX = deriv_exp_0_d0*(d_tmp1_dX);
yk = (value_exp_0+1E-64);
}
}
}
}
d_irprime_dX = (yk*d_yk_dX+d_yk_dX*(1.0+yk));
irprime = (yk*(1.0+yk));
{
double value_sqrt_0 = sqrt(irprime);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_irprime_dX = deriv_sqrt_0_d0*(d_irprime_dX);
sqrt_irprime = value_sqrt_0;
}
d_dirprime_dv_dX = d_yk_dX;
dirprime_dv = yk;
{
double value_log_0 = log((1.0+((Vds-Vip)/Lc_UCRIT)));
double  deriv_log_0_d0 = (1.0/(1.0+((Vds-Vip)/Lc_UCRIT)));
d_deltaL_dX = (Lc_LAMBDA*deriv_log_0_d0*(((Lc_UCRIT*(d_Vds_dX-d_Vip_dX)-(Vds-Vip)*d_Lc_UCRIT_dX)/Lc_UCRIT/Lc_UCRIT))+d_Lc_LAMBDA_dX*value_log_0);
deltaL = (Lc_LAMBDA*value_log_0);
}
d_Lprime_dX = ((d_Leff_dX-d_deltaL_dX)+((Vds+Vip)*d_inv_UCRIT_dX+(d_Vds_dX+d_Vip_dX)*inv_UCRIT));
Lprime = ((Leff-deltaL)+((Vds+Vip)*inv_UCRIT));
d_Lmin_dX = 0.1*d_Leff_dX;
Lmin = (0.1*Leff);
{
double value_sqrt_0 = sqrt(((Lprime*Lprime)+(Lmin*Lmin)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_Lprime_Lmin_dX = deriv_sqrt_0_d0*(((Lprime*d_Lprime_dX+d_Lprime_dX*Lprime)+(Lmin*d_Lmin_dX+d_Lmin_dX*Lmin)));
sqrt_Lprime_Lmin = value_sqrt_0;
}
d_Leq_dX = 0.5*(d_Lprime_dX+d_sqrt_Lprime_Lmin_dX);
Leq = (0.5*(Lprime+sqrt_Lprime_Lmin));
d_tmp1_dX = ((VP-VD)*d_inv_Vt_dX+(d_VP_dX-d_VD_dX)*inv_Vt);
tmp1 = ((VP-VD)*inv_Vt);
if ((tmp1>(-0.35)))
{
{
double value_log_0 = log((tmp1+1.6));
double  deriv_log_0_d0 = (1.0/(tmp1+1.6));
d_z0_dX = (-2.0*(d_tmp1_dX-deriv_log_0_d0*(d_tmp1_dX))/((1.3+tmp1)-value_log_0)/((1.3+tmp1)-value_log_0));
z0 = (2.0/((1.3+tmp1)-value_log_0));
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);
d_zk_dX = ((((1.0+tmp1)+value_log_0)*d_z0_dX-(2.0+z0)*(d_tmp1_dX+deriv_log_0_d0*(d_z0_dX)))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);
d_yk_dX = (((2.0+zk)*(d_tmp1_dX+deriv_log_0_d0*(d_zk_dX))-((1.0+tmp1)+value_log_0)*d_zk_dX)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-15.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;
d_z0_dX = deriv_exp_0_d0*((-d_tmp1_dX));
z0 = (1.55+value_exp_0);
}
{
double value_log_0 = log(z0);
double  deriv_log_0_d0 = (1.0/z0);
d_zk_dX = ((((1.0+tmp1)+value_log_0)*d_z0_dX-(2.0+z0)*(d_tmp1_dX+deriv_log_0_d0*(d_z0_dX)))/((1.0+tmp1)+value_log_0)/((1.0+tmp1)+value_log_0));
zk = ((2.0+z0)/((1.0+tmp1)+value_log_0));
}
{
double value_log_0 = log(zk);
double  deriv_log_0_d0 = (1.0/zk);
d_yk_dX = (((2.0+zk)*(d_tmp1_dX+deriv_log_0_d0*(d_zk_dX))-((1.0+tmp1)+value_log_0)*d_zk_dX)/(2.0+zk)/(2.0+zk));
yk = (((1.0+tmp1)+value_log_0)/(2.0+zk));
}
}
else
{
if ((tmp1>(-23.0)))
{
{
double value_exp_0 = exp((-tmp1));
double  deriv_exp_0_d0 = value_exp_0;
d_yk_dX = (-deriv_exp_0_d0*((-d_tmp1_dX))/(2.0+value_exp_0)/(2.0+value_exp_0));
yk = (1.0/(2.0+value_exp_0));
}
}
else
{
{
double value_exp_0 = exp(tmp1);
double  deriv_exp_0_d0 = value_exp_0;
d_yk_dX = deriv_exp_0_d0*(d_tmp1_dX);
yk = (value_exp_0+1E-64);
}
}
}
}
d_ir_dX = (yk*d_yk_dX+d_yk_dX*(1.0+yk));
ir = (yk*(1.0+yk));
{
double value_sqrt_0 = sqrt(ir);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_ir_dX = deriv_sqrt_0_d0*(d_ir_dX);
sqrt_ir = value_sqrt_0;
}
d_dir_dv_dX = d_yk_dX;
dir_dv = yk;
d_sif2_dX = d_if__dX;
sif2 = (0.25+if_);
d_sir2_dX = d_ir_dX;
sir2 = (0.25+ir);
{
double value_sqrt_0 = sqrt(sif2);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sif_dX = deriv_sqrt_0_d0*(d_sif2_dX);
sif = value_sqrt_0;
}
{
double value_sqrt_0 = sqrt(sir2);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sir_dX = deriv_sqrt_0_d0*(d_sir2_dX);
sir = value_sqrt_0;
}
d_sif_sir_2_dX = ((sif+sir)*(d_sif_dX+d_sir_dX)+(d_sif_dX+d_sir_dX)*(sif+sir));
sif_sir_2 = ((sif+sir)*(sif+sir));
d_VP_PHI_eps_dX = (d_VP_dX+d_PHI_T_dX);
VP_PHI_eps = ((VP+PHI_T)+1.0e-6);
{
double value_sqrt_0 = sqrt(VP_PHI_eps);
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_PHI_VP_2_dX = 2.0*deriv_sqrt_0_d0*(d_VP_PHI_eps_dX);
sqrt_PHI_VP_2 = (2.0*value_sqrt_0);
}
d_n_1_dX = ((sqrt_PHI_VP_2*d_GAMMA_S_dX-GAMMA_S*d_sqrt_PHI_VP_2_dX)/sqrt_PHI_VP_2/sqrt_PHI_VP_2);
n_1 = (GAMMA_S/sqrt_PHI_VP_2);
d_n_1_n_dX = (((sqrt_PHI_VP_2+GAMMA_S)*d_GAMMA_S_dX-GAMMA_S*(d_sqrt_PHI_VP_2_dX+d_GAMMA_S_dX))/(sqrt_PHI_VP_2+GAMMA_S)/(sqrt_PHI_VP_2+GAMMA_S));
n_1_n = (GAMMA_S/(sqrt_PHI_VP_2+GAMMA_S));
d_qi_dX = (((-(1.0+n_1))*Vt)*(((sif+sir)*(0.66666666+0.66666666)*((d_sir2_dX+(sir*d_sif_dX+d_sir_dX*sif))+d_sif2_dX)-((0.66666666+0.66666666)*((sir2+(sir*sif))+sif2))*(d_sif_dX+d_sir_dX))/(sif+sir)/(sif+sir))+((-(1.0+n_1))*d_Vt_dX+(-d_n_1_dX)*Vt)*((((0.66666666+0.66666666)*((sir2+(sir*sif))+sif2))/(sif+sir))-1.0));
qi = (((-(1.0+n_1))*Vt)*((((0.66666666+0.66666666)*((sir2+(sir*sif))+sif2))/(sif+sir))-1.0));
d_qb_dX = ((((-0.5)*GAMMA_S)*d_sqrt_PHI_VP_2_dX+(-0.5)*d_GAMMA_S_dX*sqrt_PHI_VP_2)-(n_1_n*d_qi_dX+d_n_1_n_dX*qi));
qb = ((((-0.5)*GAMMA_S)*sqrt_PHI_VP_2)-(n_1_n*qi));
if ((modelStruct.modelPar_E0==0.0))
{
{
double value_sqrt_0 = sqrt(((VP*VP)+Vt_Vt_2));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_VP_Vt_dX = deriv_sqrt_0_d0*(((VP*d_VP_dX+d_VP_dX*VP)+d_Vt_Vt_2_dX));
sqrt_VP_Vt = value_sqrt_0;
}
d_VPprime_dX = 0.5*(d_VP_dX+d_sqrt_VP_Vt_dX);
VPprime = (0.5*(VP+sqrt_VP_Vt));
d_THETA_VP_1_dX = (modelStruct.modelPar_THETA*d_VPprime_dX+modelStruct.d_modelPar_THETA_dX*VPprime);
THETA_VP_1 = (1.0+(modelStruct.modelPar_THETA*VPprime));
d_beta_dX = (((Leq*THETA_VP_1)*d_KP_Weff_dX-KP_Weff*(Leq*d_THETA_VP_1_dX+d_Leq_dX*THETA_VP_1))/(Leq*THETA_VP_1)/(Leq*THETA_VP_1));
beta = (KP_Weff/(Leq*THETA_VP_1));
}
else
{
if (((qb+(eta_qi*qi))>0.0))
{
d_E0_Q_1_dX = (T0*(d_qb_dX+(eta_qi*d_qi_dX+d_eta_qi_dX*qi))+d_T0_dX*(qb+(eta_qi*qi)));
E0_Q_1 = (1.0+(T0*(qb+(eta_qi*qi))));
}
else
{
d_E0_Q_1_dX = (-(T0*(d_qb_dX+(eta_qi*d_qi_dX+d_eta_qi_dX*qi))+d_T0_dX*(qb+(eta_qi*qi))));
E0_Q_1 = (1.0-(T0*(qb+(eta_qi*qi))));
}
d_T0_GAMMA_1_dX = (T0*d_GAMMA_sqrt_PHI_dX+d_T0_dX*GAMMA_sqrt_PHI);
T0_GAMMA_1 = (1.0+(T0*GAMMA_sqrt_PHI));
d_beta_dX = (((Leq*E0_Q_1)*(KP_Weff*d_T0_GAMMA_1_dX+d_KP_Weff_dX*T0_GAMMA_1)-(KP_Weff*T0_GAMMA_1)*(Leq*d_E0_Q_1_dX+d_Leq_dX*E0_Q_1))/(Leq*E0_Q_1)/(Leq*E0_Q_1));
beta = ((KP_Weff*T0_GAMMA_1)/(Leq*E0_Q_1));
}
{
double value_sqrt_0 = sqrt(((PHI_T+VP)+Vt_4));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_sqrt_PHI_VP_dX = deriv_sqrt_0_d0*(((d_PHI_T_dX+d_VP_dX)+d_Vt_4_dX));
sqrt_PHI_VP = value_sqrt_0;
}
d_n_dX = (((2.0*sqrt_PHI_VP)*d_GAMMA_S_dX-GAMMA_S*2.0*d_sqrt_PHI_VP_dX)/(2.0*sqrt_PHI_VP)/(2.0*sqrt_PHI_VP));
n = (1.0+(GAMMA_S/(2.0*sqrt_PHI_VP)));
d_if_ir_dX = (d_if__dX-d_irprime_dX);
if_ir = (if_-irprime);
d_Ispec_dX = ((Vt_Vt_2*n)*d_beta_dX+(Vt_Vt_2*d_n_dX+d_Vt_Vt_2_dX*n)*beta);
Ispec = ((Vt_Vt_2*n)*beta);
d_Id_dX = (Ispec*d_if_ir_dX+d_Ispec_dX*if_ir);
Id = (Ispec*if_ir);
d_Von_dX = (d_VTO_S_dX+(GAMMAprime*(d_sqrt_PHI_VS_dX-d_sqrt_PHI_dX)+d_GAMMAprime_dX*(sqrt_PHI_VS-sqrt_PHI)));
Von = (VTO_S+(GAMMAprime*(sqrt_PHI_VS-sqrt_PHI)));
d_Vdsat_dX = (Vt*2.0*d_sqrt_if_dX+d_Vt_dX*((2.0*sqrt_if)+4.0));
Vdsat = (Vt*((2.0*sqrt_if)+4.0));
{
double value_fabs_0 = fabs(qi);
double  deriv_fabs_0_d0 = (((qi)>=0)?(+1.0):(-1.0));
d_Gn_dX = (beta*deriv_fabs_0_d0*(d_qi_dX)+d_beta_dX*value_fabs_0);
Gn = (beta*value_fabs_0);
}
d_tmp1_dX = (((sqrt_GAMMAstar+sqrt_GAMMAstar)*d_GAMMAprime_dX-GAMMAprime*(d_sqrt_GAMMAstar_dX+d_sqrt_GAMMAstar_dX))/(sqrt_GAMMAstar+sqrt_GAMMAstar)/(sqrt_GAMMAstar+sqrt_GAMMAstar));
tmp1 = (GAMMAprime/(sqrt_GAMMAstar+sqrt_GAMMAstar));
d_tmp2_dX = ((sqrt_VGstar*d_VGprime_dX-VGprime*d_sqrt_VGstar_dX)/sqrt_VGstar/sqrt_VGstar);
tmp2 = (VGprime/sqrt_VGstar);
d_dGAMMAprime_dVD_dX = ((sqrt_PHI_VD_Vt*(((-LETA_L)*tmp1)*d_sqrt_PHI_VD_dX+((-LETA_L)*d_tmp1_dX+(-d_LETA_L_dX)*tmp1)*sqrt_PHI_VD)-(((-LETA_L)*tmp1)*sqrt_PHI_VD)*d_sqrt_PHI_VD_Vt_dX)/sqrt_PHI_VD_Vt/sqrt_PHI_VD_Vt);
dGAMMAprime_dVD = ((((-LETA_L)*tmp1)*sqrt_PHI_VD)/sqrt_PHI_VD_Vt);
d_dGAMMAprime_dVS_dX = ((sqrt_PHI_VS_Vt*(((-LETA_L)*tmp1)*d_sqrt_PHI_VS_dX+((-LETA_L)*d_tmp1_dX+(-d_LETA_L_dX)*tmp1)*sqrt_PHI_VS)-(((-LETA_L)*tmp1)*sqrt_PHI_VS)*d_sqrt_PHI_VS_Vt_dX)/sqrt_PHI_VS_Vt/sqrt_PHI_VS_Vt);
dGAMMAprime_dVS = ((((-LETA_L)*tmp1)*sqrt_PHI_VS)/sqrt_PHI_VS_Vt);
d_dGAMMAprime_dVG_dX = ((((WETA_W*tmp1)*(big_sqrt_VP0-(0.5*GAMMA_S)))/(big_sqrt_VP0*sqrt_PHI_VP0))*d_tmp2_dX+(((big_sqrt_VP0*sqrt_PHI_VP0)*((WETA_W*tmp1)*(d_big_sqrt_VP0_dX-0.5*d_GAMMA_S_dX)+(WETA_W*d_tmp1_dX+d_WETA_W_dX*tmp1)*(big_sqrt_VP0-(0.5*GAMMA_S)))-((WETA_W*tmp1)*(big_sqrt_VP0-(0.5*GAMMA_S)))*(big_sqrt_VP0*d_sqrt_PHI_VP0_dX+d_big_sqrt_VP0_dX*sqrt_PHI_VP0))/(big_sqrt_VP0*sqrt_PHI_VP0)/(big_sqrt_VP0*sqrt_PHI_VP0))*tmp2);
dGAMMAprime_dVG = ((((WETA_W*tmp1)*(big_sqrt_VP0-(0.5*GAMMA_S)))/(big_sqrt_VP0*sqrt_PHI_VP0))*tmp2);
d_tmp3_dX = ((big_sqrt_VP*(d_VP_dX+d_PHI_T_dX)-(VP+PHI_T)*d_big_sqrt_VP_dX)/big_sqrt_VP/big_sqrt_VP);
tmp3 = ((VP+PHI_T)/big_sqrt_VP);
d_dVP_dVD_dX = ((-tmp3)*d_dGAMMAprime_dVD_dX+(-d_tmp3_dX)*dGAMMAprime_dVD);
dVP_dVD = ((-tmp3)*dGAMMAprime_dVD);
d_dVP_dVS_dX = ((-tmp3)*d_dGAMMAprime_dVS_dX+(-d_tmp3_dX)*dGAMMAprime_dVS);
dVP_dVS = ((-tmp3)*dGAMMAprime_dVS);
d_dVP_dVG_dX = (((-tmp3)*d_dGAMMAprime_dVG_dX+(-d_tmp3_dX)*dGAMMAprime_dVG)+((1.0-(GAMMAprime/(big_sqrt_VP+big_sqrt_VP)))*d_tmp2_dX+(-(((big_sqrt_VP+big_sqrt_VP)*d_GAMMAprime_dX-GAMMAprime*(d_big_sqrt_VP_dX+d_big_sqrt_VP_dX))/(big_sqrt_VP+big_sqrt_VP)/(big_sqrt_VP+big_sqrt_VP)))*tmp2));
dVP_dVG = (((-tmp3)*dGAMMAprime_dVG)+((1.0-(GAMMAprime/(big_sqrt_VP+big_sqrt_VP)))*tmp2));
d_tmp1_dX = (dif_dv*d_inv_Vt_dX+d_dif_dv_dX*inv_Vt);
tmp1 = (dif_dv*inv_Vt);
d_dif_dVD_dX = (tmp1*d_dVP_dVD_dX+d_tmp1_dX*dVP_dVD);
dif_dVD = (tmp1*dVP_dVD);
d_dif_dVS_dX = (tmp1*d_dVP_dVS_dX+d_tmp1_dX*(dVP_dVS-1.0));
dif_dVS = (tmp1*(dVP_dVS-1.0));
d_dif_dVG_dX = (tmp1*d_dVP_dVG_dX+d_tmp1_dX*dVP_dVG);
dif_dVG = (tmp1*dVP_dVG);
d_tmp1_dX = ((((4.0*VDSS_sqrt)*sqrt_if)*d_Vt_dX-Vt*((4.0*VDSS_sqrt)*d_sqrt_if_dX+4.0*d_VDSS_sqrt_dX*sqrt_if))/((4.0*VDSS_sqrt)*sqrt_if)/((4.0*VDSS_sqrt)*sqrt_if));
tmp1 = (Vt/((4.0*VDSS_sqrt)*sqrt_if));
d_dVDSS_dVD_dX = (tmp1*d_dif_dVD_dX+d_tmp1_dX*dif_dVD);
dVDSS_dVD = (tmp1*dif_dVD);
d_dVDSS_dVS_dX = (tmp1*d_dif_dVS_dX+d_tmp1_dX*dif_dVS);
dVDSS_dVS = (tmp1*dif_dVS);
d_dVDSS_dVG_dX = (tmp1*d_dif_dVG_dX+d_tmp1_dX*dif_dVG);
dVDSS_dVG = (tmp1*dif_dVG);
d_tmp1_dX = ((Vt_4+Vt_4)*modelStruct.d_modelPar_LAMBDA_dX+(d_Vt_4_dX+d_Vt_4_dX)*modelStruct.modelPar_LAMBDA);
tmp1 = ((Vt_4+Vt_4)*modelStruct.modelPar_LAMBDA);
d_tmp2_dX = (((sqrt_if+sqrt_if)*d_Vt_dX-Vt*(d_sqrt_if_dX+d_sqrt_if_dX))/(sqrt_if+sqrt_if)/(sqrt_if+sqrt_if));
tmp2 = (Vt/(sqrt_if+sqrt_if));
d_ddeltaV_dVD_dX = (tmp1*((dif_dVD*d_tmp2_dX+d_dif_dVD_dX*tmp2)-d_dVDSS_dVD_dX)+d_tmp1_dX*((dif_dVD*tmp2)-dVDSS_dVD));
ddeltaV_dVD = (tmp1*((dif_dVD*tmp2)-dVDSS_dVD));
d_ddeltaV_dVS_dX = (tmp1*((dif_dVS*d_tmp2_dX+d_dif_dVS_dX*tmp2)-d_dVDSS_dVS_dX)+d_tmp1_dX*((dif_dVS*tmp2)-dVDSS_dVS));
ddeltaV_dVS = (tmp1*((dif_dVS*tmp2)-dVDSS_dVS));
d_ddeltaV_dVG_dX = (tmp1*((dif_dVG*d_tmp2_dX+d_dif_dVG_dX*tmp2)-d_dVDSS_dVG_dX)+d_tmp1_dX*((dif_dVG*tmp2)-dVDSS_dVG));
ddeltaV_dVG = (tmp1*((dif_dVG*tmp2)-dVDSS_dVG));
d_tmp1_dX = (-d_sqrt_VDSS_deltaV_dX/sqrt_VDSS_deltaV/sqrt_VDSS_deltaV);
tmp1 = (1.0/sqrt_VDSS_deltaV);
d_tmp2_dX = (-d_sqrt_Vds_VDSS_deltaV_dX/sqrt_Vds_VDSS_deltaV/sqrt_Vds_VDSS_deltaV);
tmp2 = (1.0/sqrt_Vds_VDSS_deltaV);
d_tmp3_dX = (d_Vds_dX-d_VDSS_dX);
tmp3 = (Vds-VDSS);
d_dVip_dVD_dX = ((((VDSS*dVDSS_dVD)+ddeltaV_dVD)*d_tmp1_dX+((VDSS*d_dVDSS_dVD_dX+d_VDSS_dX*dVDSS_dVD)+d_ddeltaV_dVD_dX)*tmp1)-(((tmp3*(0.5-dVDSS_dVD))+ddeltaV_dVD)*d_tmp2_dX+((tmp3*(-d_dVDSS_dVD_dX)+d_tmp3_dX*(0.5-dVDSS_dVD))+d_ddeltaV_dVD_dX)*tmp2));
dVip_dVD = ((((VDSS*dVDSS_dVD)+ddeltaV_dVD)*tmp1)-(((tmp3*(0.5-dVDSS_dVD))+ddeltaV_dVD)*tmp2));
d_dVip_dVS_dX = ((((VDSS*dVDSS_dVS)+ddeltaV_dVS)*d_tmp1_dX+((VDSS*d_dVDSS_dVS_dX+d_VDSS_dX*dVDSS_dVS)+d_ddeltaV_dVS_dX)*tmp1)-(((tmp3*((-0.5)-dVDSS_dVS))+ddeltaV_dVS)*d_tmp2_dX+((tmp3*(-d_dVDSS_dVS_dX)+d_tmp3_dX*((-0.5)-dVDSS_dVS))+d_ddeltaV_dVS_dX)*tmp2));
dVip_dVS = ((((VDSS*dVDSS_dVS)+ddeltaV_dVS)*tmp1)-(((tmp3*((-0.5)-dVDSS_dVS))+ddeltaV_dVS)*tmp2));
d_dVip_dVG_dX = ((((VDSS*dVDSS_dVG)+ddeltaV_dVG)*d_tmp1_dX+((VDSS*d_dVDSS_dVG_dX+d_VDSS_dX*dVDSS_dVG)+d_ddeltaV_dVG_dX)*tmp1)-(((tmp3*(-dVDSS_dVG))+ddeltaV_dVG)*d_tmp2_dX+((tmp3*(-d_dVDSS_dVG_dX)+d_tmp3_dX*(-dVDSS_dVG))+d_ddeltaV_dVG_dX)*tmp2));
dVip_dVG = ((((VDSS*dVDSS_dVG)+ddeltaV_dVG)*tmp1)-(((tmp3*(-dVDSS_dVG))+ddeltaV_dVG)*tmp2));
d_tmp1_dX = ((((4.0*VDSSprime_sqrt)*if_)*(Vt*d_sqrt_if_dX+d_Vt_dX*(sqrt_if-1.5))-(Vt*(sqrt_if-1.5))*((4.0*VDSSprime_sqrt)*d_if__dX+4.0*d_VDSSprime_sqrt_dX*if_))/((4.0*VDSSprime_sqrt)*if_)/((4.0*VDSSprime_sqrt)*if_));
tmp1 = ((Vt*(sqrt_if-1.5))/((4.0*VDSSprime_sqrt)*if_));
d_dVDSSprime_dVD_dX = (tmp1*d_dif_dVD_dX+d_tmp1_dX*dif_dVD);
dVDSSprime_dVD = (tmp1*dif_dVD);
d_dVDSSprime_dVS_dX = (tmp1*d_dif_dVS_dX+d_tmp1_dX*dif_dVS);
dVDSSprime_dVS = (tmp1*dif_dVS);
d_dVDSSprime_dVG_dX = (tmp1*d_dif_dVG_dX+d_tmp1_dX*dif_dVG);
dVDSSprime_dVG = (tmp1*dif_dVG);
d_tmp1_dX = (dirprime_dv*d_inv_Vt_dX+d_dirprime_dv_dX*inv_Vt);
tmp1 = (dirprime_dv*inv_Vt);
d_tmp2_dX = (-d_sqrt_VDSSprime_deltaV_dX/sqrt_VDSSprime_deltaV/sqrt_VDSSprime_deltaV);
tmp2 = (1.0/sqrt_VDSSprime_deltaV);
d_tmp3_dX = (-d_sqrt_Vds_VDSSprime_deltaV_dX/sqrt_Vds_VDSSprime_deltaV/sqrt_Vds_VDSSprime_deltaV);
tmp3 = (1.0/sqrt_Vds_VDSSprime_deltaV);
d_dirprime_dVD_dX = (tmp1*((d_dVP_dVD_dX-(((VDSSprime*dVDSSprime_dVD)+ddeltaV_dVD)*d_tmp2_dX+((VDSSprime*d_dVDSSprime_dVD_dX+d_VDSSprime_dX*dVDSSprime_dVD)+d_ddeltaV_dVD_dX)*tmp2))+(((Vdsprime*(0.5-dVDSSprime_dVD))+ddeltaV_dVD)*d_tmp3_dX+((Vdsprime*(-d_dVDSSprime_dVD_dX)+d_Vdsprime_dX*(0.5-dVDSSprime_dVD))+d_ddeltaV_dVD_dX)*tmp3))+d_tmp1_dX*(((dVP_dVD-0.5)-(((VDSSprime*dVDSSprime_dVD)+ddeltaV_dVD)*tmp2))+(((Vdsprime*(0.5-dVDSSprime_dVD))+ddeltaV_dVD)*tmp3)));
dirprime_dVD = (tmp1*(((dVP_dVD-0.5)-(((VDSSprime*dVDSSprime_dVD)+ddeltaV_dVD)*tmp2))+(((Vdsprime*(0.5-dVDSSprime_dVD))+ddeltaV_dVD)*tmp3)));
d_dirprime_dVS_dX = (tmp1*((d_dVP_dVS_dX-(((VDSSprime*dVDSSprime_dVS)+ddeltaV_dVS)*d_tmp2_dX+((VDSSprime*d_dVDSSprime_dVS_dX+d_VDSSprime_dX*dVDSSprime_dVS)+d_ddeltaV_dVS_dX)*tmp2))+(((Vdsprime*((-0.5)-dVDSSprime_dVS))+ddeltaV_dVS)*d_tmp3_dX+((Vdsprime*(-d_dVDSSprime_dVS_dX)+d_Vdsprime_dX*((-0.5)-dVDSSprime_dVS))+d_ddeltaV_dVS_dX)*tmp3))+d_tmp1_dX*(((dVP_dVS-0.5)-(((VDSSprime*dVDSSprime_dVS)+ddeltaV_dVS)*tmp2))+(((Vdsprime*((-0.5)-dVDSSprime_dVS))+ddeltaV_dVS)*tmp3)));
dirprime_dVS = (tmp1*(((dVP_dVS-0.5)-(((VDSSprime*dVDSSprime_dVS)+ddeltaV_dVS)*tmp2))+(((Vdsprime*((-0.5)-dVDSSprime_dVS))+ddeltaV_dVS)*tmp3)));
d_dirprime_dVG_dX = (tmp1*((d_dVP_dVG_dX-(((VDSSprime*dVDSSprime_dVG)+ddeltaV_dVG)*d_tmp2_dX+((VDSSprime*d_dVDSSprime_dVG_dX+d_VDSSprime_dX*dVDSSprime_dVG)+d_ddeltaV_dVG_dX)*tmp2))+(((Vdsprime*(-dVDSSprime_dVG))+ddeltaV_dVG)*d_tmp3_dX+((Vdsprime*(-d_dVDSSprime_dVG_dX)+d_Vdsprime_dX*(-dVDSSprime_dVG))+d_ddeltaV_dVG_dX)*tmp3))+d_tmp1_dX*((dVP_dVG-(((VDSSprime*dVDSSprime_dVG)+ddeltaV_dVG)*tmp2))+(((Vdsprime*(-dVDSSprime_dVG))+ddeltaV_dVG)*tmp3)));
dirprime_dVG = (tmp1*((dVP_dVG-(((VDSSprime*dVDSSprime_dVG)+ddeltaV_dVG)*tmp2))+(((Vdsprime*(-dVDSSprime_dVG))+ddeltaV_dVG)*tmp3)));
d_tmp1_dX = ((((Lc_UCRIT+Vds)-Vip)*d_Lc_LAMBDA_dX-Lc_LAMBDA*((d_Lc_UCRIT_dX+d_Vds_dX)-d_Vip_dX))/((Lc_UCRIT+Vds)-Vip)/((Lc_UCRIT+Vds)-Vip));
tmp1 = (Lc_LAMBDA/((Lc_UCRIT+Vds)-Vip));
d_ddeltaL_dVD_dX = (tmp1*(-d_dVip_dVD_dX)+d_tmp1_dX*(0.5-dVip_dVD));
ddeltaL_dVD = (tmp1*(0.5-dVip_dVD));
d_ddeltaL_dVS_dX = (tmp1*(-d_dVip_dVS_dX)+d_tmp1_dX*((-0.5)-dVip_dVS));
ddeltaL_dVS = (tmp1*((-0.5)-dVip_dVS));
d_ddeltaL_dVG_dX = ((-tmp1)*d_dVip_dVG_dX+(-d_tmp1_dX)*dVip_dVG);
ddeltaL_dVG = ((-tmp1)*dVip_dVG);
d_tmp1_dX = (-d_sqrt_Lprime_Lmin_dX/sqrt_Lprime_Lmin/sqrt_Lprime_Lmin);
tmp1 = (1.0/sqrt_Lprime_Lmin);
d_dLeq_dVD_dX = (tmp1*((-d_ddeltaL_dVD_dX)+((0.5+dVip_dVD)*d_inv_UCRIT_dX+d_dVip_dVD_dX*inv_UCRIT))+d_tmp1_dX*((-ddeltaL_dVD)+((0.5+dVip_dVD)*inv_UCRIT)));
dLeq_dVD = (tmp1*((-ddeltaL_dVD)+((0.5+dVip_dVD)*inv_UCRIT)));
d_dLeq_dVS_dX = (tmp1*((-d_ddeltaL_dVS_dX)+(((-0.5)+dVip_dVS)*d_inv_UCRIT_dX+d_dVip_dVS_dX*inv_UCRIT))+d_tmp1_dX*((-ddeltaL_dVS)+(((-0.5)+dVip_dVS)*inv_UCRIT)));
dLeq_dVS = (tmp1*((-ddeltaL_dVS)+(((-0.5)+dVip_dVS)*inv_UCRIT)));
d_dLeq_dVG_dX = (tmp1*((-d_ddeltaL_dVG_dX)+(dVip_dVG*d_inv_UCRIT_dX+d_dVip_dVG_dX*inv_UCRIT))+d_tmp1_dX*((-ddeltaL_dVG)+(dVip_dVG*inv_UCRIT)));
dLeq_dVG = (tmp1*((-ddeltaL_dVG)+(dVip_dVG*inv_UCRIT)));
d_tmp1_dX = (dir_dv*d_inv_Vt_dX+d_dir_dv_dX*inv_Vt);
tmp1 = (dir_dv*inv_Vt);
d_dir_dVD_dX = (tmp1*d_dVP_dVD_dX+d_tmp1_dX*(dVP_dVD-1.0));
dir_dVD = (tmp1*(dVP_dVD-1.0));
d_dir_dVS_dX = (tmp1*d_dVP_dVS_dX+d_tmp1_dX*dVP_dVS);
dir_dVS = (tmp1*dVP_dVS);
d_dir_dVG_dX = (tmp1*d_dVP_dVG_dX+d_tmp1_dX*dVP_dVG);
dir_dVG = (tmp1*dVP_dVG);
d_tmp1_dX = ((sif_sir_2*((-(1.0+n_1))*d_Vt_dX+(-d_n_1_dX)*Vt)*0.66666666-(((-(1.0+n_1))*Vt)*0.66666666)*d_sif_sir_2_dX)/sif_sir_2/sif_sir_2);
tmp1 = ((((-(1.0+n_1))*Vt)*0.66666666)/sif_sir_2);
d_tmp2_dX = (tmp1*(d_sif_dX+2.0*d_sir_dX)+d_tmp1_dX*(sif+(2.0*sir)));
tmp2 = (tmp1*(sif+(2.0*sir)));
d_tmp3_dX = (tmp1*(d_sir_dX+2.0*d_sif_dX)+d_tmp1_dX*(sir+(2.0*sif)));
tmp3 = (tmp1*(sir+(2.0*sif)));
d_tmp1_dX = (((((2.0+n_1)+n_1)*VP_PHI_eps)*((-n_1)*d_qi_dX+(-d_n_1_dX)*qi)-((-n_1)*qi)*(((2.0+n_1)+n_1)*d_VP_PHI_eps_dX+(d_n_1_dX+d_n_1_dX)*VP_PHI_eps))/(((2.0+n_1)+n_1)*VP_PHI_eps)/(((2.0+n_1)+n_1)*VP_PHI_eps));
tmp1 = (((-n_1)*qi)/(((2.0+n_1)+n_1)*VP_PHI_eps));
d_dQI_dVD_dX = (((tmp1*d_dVP_dVD_dX+d_tmp1_dX*dVP_dVD)+(tmp2*d_dif_dVD_dX+d_tmp2_dX*dif_dVD))+(tmp3*d_dir_dVD_dX+d_tmp3_dX*dir_dVD));
dQI_dVD = (((tmp1*dVP_dVD)+(tmp2*dif_dVD))+(tmp3*dir_dVD));
d_dQI_dVS_dX = (((tmp1*d_dVP_dVS_dX+d_tmp1_dX*dVP_dVS)+(tmp2*d_dif_dVS_dX+d_tmp2_dX*dif_dVS))+(tmp3*d_dir_dVS_dX+d_tmp3_dX*dir_dVS));
dQI_dVS = (((tmp1*dVP_dVS)+(tmp2*dif_dVS))+(tmp3*dir_dVS));
d_dQI_dVG_dX = (((tmp1*d_dVP_dVG_dX+d_tmp1_dX*dVP_dVG)+(tmp2*d_dif_dVG_dX+d_tmp2_dX*dif_dVG))+(tmp3*d_dir_dVG_dX+d_tmp3_dX*dir_dVG));
dQI_dVG = (((tmp1*dVP_dVG)+(tmp2*dif_dVG))+(tmp3*dir_dVG));
d_tmp1_dX = (d_n_1_dX-((((2.0*(1.0+n_1))*VP_PHI_eps)*d_qi_dX-qi*((2.0*(1.0+n_1))*d_VP_PHI_eps_dX+2.0*d_n_1_dX*VP_PHI_eps))/((2.0*(1.0+n_1))*VP_PHI_eps)/((2.0*(1.0+n_1))*VP_PHI_eps)));
tmp1 = ((1.0+n_1)-(qi/((2.0*(1.0+n_1))*VP_PHI_eps)));
d_dQB_dVD_dX = ((-n_1_n)*((tmp1*d_dVP_dVD_dX+d_tmp1_dX*dVP_dVD)+d_dQI_dVD_dX)+(-d_n_1_n_dX)*((tmp1*dVP_dVD)+dQI_dVD));
dQB_dVD = ((-n_1_n)*((tmp1*dVP_dVD)+dQI_dVD));
d_dQB_dVS_dX = ((-n_1_n)*((tmp1*d_dVP_dVS_dX+d_tmp1_dX*dVP_dVS)+d_dQI_dVS_dX)+(-d_n_1_n_dX)*((tmp1*dVP_dVS)+dQI_dVS));
dQB_dVS = ((-n_1_n)*((tmp1*dVP_dVS)+dQI_dVS));
d_dQB_dVG_dX = ((-n_1_n)*((tmp1*d_dVP_dVG_dX+d_tmp1_dX*dVP_dVG)+d_dQI_dVG_dX)+(-d_n_1_n_dX)*((tmp1*dVP_dVG)+dQI_dVG));
dQB_dVG = ((-n_1_n)*((tmp1*dVP_dVG)+dQI_dVG));
if ((modelStruct.modelPar_E0==0.0))
{
d_tmp1_dX = (((THETA_VP_1*sqrt_VP_Vt)*(modelStruct.modelPar_THETA*d_VPprime_dX+modelStruct.d_modelPar_THETA_dX*VPprime)-(modelStruct.modelPar_THETA*VPprime)*(THETA_VP_1*d_sqrt_VP_Vt_dX+d_THETA_VP_1_dX*sqrt_VP_Vt))/(THETA_VP_1*sqrt_VP_Vt)/(THETA_VP_1*sqrt_VP_Vt));
tmp1 = ((modelStruct.modelPar_THETA*VPprime)/(THETA_VP_1*sqrt_VP_Vt));
d_dVPprime_dVD_dX = (tmp1*d_dVP_dVD_dX+d_tmp1_dX*dVP_dVD);
dVPprime_dVD = (tmp1*dVP_dVD);
d_dVPprime_dVS_dX = (tmp1*d_dVP_dVS_dX+d_tmp1_dX*dVP_dVS);
dVPprime_dVS = (tmp1*dVP_dVS);
d_dVPprime_dVG_dX = (tmp1*d_dVP_dVG_dX+d_tmp1_dX*dVP_dVG);
dVPprime_dVG = (tmp1*dVP_dVG);
d_dbeta_dVD_dX = ((-d_dLeq_dVD_dX)-d_dVPprime_dVD_dX);
dbeta_dVD = ((-dLeq_dVD)-dVPprime_dVD);
d_dbeta_dVS_dX = ((-d_dLeq_dVS_dX)-d_dVPprime_dVS_dX);
dbeta_dVS = ((-dLeq_dVS)-dVPprime_dVS);
d_dbeta_dVG_dX = ((-d_dLeq_dVG_dX)-d_dVPprime_dVG_dX);
dbeta_dVG = ((-dLeq_dVG)-dVPprime_dVG);
}
else
{
d_tmp1_dX = ((E0_Q_1*d_T0_dX-T0*d_E0_Q_1_dX)/E0_Q_1/E0_Q_1);
tmp1 = (T0/E0_Q_1);
d_dbeta_dVD_dX = ((-d_dLeq_dVD_dX)+(tmp1*(d_dQB_dVD_dX+(eta_qi*d_dQI_dVD_dX+d_eta_qi_dX*dQI_dVD))+d_tmp1_dX*(dQB_dVD+(eta_qi*dQI_dVD))));
dbeta_dVD = ((-dLeq_dVD)+(tmp1*(dQB_dVD+(eta_qi*dQI_dVD))));
d_dbeta_dVS_dX = ((-d_dLeq_dVS_dX)+(tmp1*(d_dQB_dVS_dX+(eta_qi*d_dQI_dVS_dX+d_eta_qi_dX*dQI_dVS))+d_tmp1_dX*(dQB_dVS+(eta_qi*dQI_dVS))));
dbeta_dVS = ((-dLeq_dVS)+(tmp1*(dQB_dVS+(eta_qi*dQI_dVS))));
d_dbeta_dVG_dX = ((-d_dLeq_dVG_dX)+(tmp1*(d_dQB_dVG_dX+(eta_qi*d_dQI_dVG_dX+d_eta_qi_dX*dQI_dVG))+d_tmp1_dX*(dQB_dVG+(eta_qi*dQI_dVG))));
dbeta_dVG = ((-dLeq_dVG)+(tmp1*(dQB_dVG+(eta_qi*dQI_dVG))));
}
d_tmp1_dX = (((((4.0*n)*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4))*(-d_GAMMA_S_dX)-(-GAMMA_S)*(((4.0*n)*sqrt_PHI_VP)*((d_PHI_T_dX+d_VP_dX)+d_Vt_4_dX)+((4.0*n)*d_sqrt_PHI_VP_dX+4.0*d_n_dX*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4)))/(((4.0*n)*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4))/(((4.0*n)*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4)));
tmp1 = ((-GAMMA_S)/(((4.0*n)*sqrt_PHI_VP)*((PHI_T+VP)+Vt_4)));
d_dn_dVD_dX = (tmp1*d_dVP_dVD_dX+d_tmp1_dX*dVP_dVD);
dn_dVD = (tmp1*dVP_dVD);
d_dn_dVS_dX = (tmp1*d_dVP_dVS_dX+d_tmp1_dX*dVP_dVS);
dn_dVS = (tmp1*dVP_dVS);
d_dn_dVG_dX = (tmp1*d_dVP_dVG_dX+d_tmp1_dX*dVP_dVG);
dn_dVG = (tmp1*dVP_dVG);
d_gds_dX = (Ispec*((((dn_dVD+dbeta_dVD)*d_if_ir_dX+(d_dn_dVD_dX+d_dbeta_dVD_dX)*if_ir)+d_dif_dVD_dX)-d_dirprime_dVD_dX)+d_Ispec_dX*((((dn_dVD+dbeta_dVD)*if_ir)+dif_dVD)-dirprime_dVD));
gds = (Ispec*((((dn_dVD+dbeta_dVD)*if_ir)+dif_dVD)-dirprime_dVD));
d_gms_dX = ((-Ispec)*((((dn_dVS+dbeta_dVS)*d_if_ir_dX+(d_dn_dVS_dX+d_dbeta_dVS_dX)*if_ir)+d_dif_dVS_dX)-d_dirprime_dVS_dX)+(-d_Ispec_dX)*((((dn_dVS+dbeta_dVS)*if_ir)+dif_dVS)-dirprime_dVS));
gms = ((-Ispec)*((((dn_dVS+dbeta_dVS)*if_ir)+dif_dVS)-dirprime_dVS));
d_gm_dX = (Ispec*((((dn_dVG+dbeta_dVG)*d_if_ir_dX+(d_dn_dVG_dX+d_dbeta_dVG_dX)*if_ir)+d_dif_dVG_dX)-d_dirprime_dVG_dX)+d_Ispec_dX*((((dn_dVG+dbeta_dVG)*if_ir)+dif_dVG)-dirprime_dVG));
gm = (Ispec*((((dn_dVG+dbeta_dVG)*if_ir)+dif_dVG)-dirprime_dVG));
d_gmbs_dX = ((d_gms_dX-d_gm_dX)-d_gds_dX);
gmbs = ((gms-gm)-gds);
d_RSeff_dX = (((Weff-modelStruct.modelPar_DW)*(modelStruct.modelPar_RSH*modelStruct.d_modelPar_HDIF_dX+modelStruct.d_modelPar_RSH_dX*modelStruct.modelPar_HDIF)-(modelStruct.modelPar_RSH*modelStruct.modelPar_HDIF)*(d_Weff_dX-modelStruct.d_modelPar_DW_dX))/(Weff-modelStruct.modelPar_DW)/(Weff-modelStruct.modelPar_DW));
RSeff = ((modelStruct.modelPar_RSH*modelStruct.modelPar_HDIF)/(Weff-modelStruct.modelPar_DW));
d_RDeff_dX = (((Weff-modelStruct.modelPar_DW)*(modelStruct.modelPar_RSH*modelStruct.d_modelPar_HDIF_dX+modelStruct.d_modelPar_RSH_dX*modelStruct.modelPar_HDIF)-(modelStruct.modelPar_RSH*modelStruct.modelPar_HDIF)*(d_Weff_dX-modelStruct.d_modelPar_DW_dX))/(Weff-modelStruct.modelPar_DW)/(Weff-modelStruct.modelPar_DW));
RDeff = ((modelStruct.modelPar_RSH*modelStruct.modelPar_HDIF)/(Weff-modelStruct.modelPar_DW));
d_tmp1_dX = (-((gms*d_RSeff_dX+d_gms_dX*RSeff)+(gds*d_RDeff_dX+d_gds_dX*RDeff))/((1.0+(gms*RSeff))+(gds*RDeff))/((1.0+(gms*RSeff))+(gds*RDeff)));
tmp1 = (1.0/((1.0+(gms*RSeff))+(gds*RDeff)));
d_Id_dX = (Id*d_tmp1_dX+d_Id_dX*tmp1);
Id = (Id*tmp1);
d_Vib_dX = ((d_VD_dX-d_VS_dX)-(IBN_2*d_VDSS_dX+d_IBN_2_dX*VDSS));
Vib = ((VD-VS)-(IBN_2*VDSS));
if (((Vib>0.0)&&(IBA_IBB>0.0)))
{
d_inv_Vib_dX = (-d_Vib_dX/Vib/Vib);
inv_Vib = (1.0/Vib);
d_Lc_IBB_Vib_dX = ((-Lc_IBB)*d_inv_Vib_dX+(-d_Lc_IBB_dX)*inv_Vib);
Lc_IBB_Vib = ((-Lc_IBB)*inv_Vib);
if ((Lc_IBB_Vib<(-35.0)))
{
d_Lc_IBB_Vib_dX = 0.0;
Lc_IBB_Vib = (-35.0);
}
{
double value_exp_0 = exp(Lc_IBB_Vib);
double  deriv_exp_0_d0 = value_exp_0;
d_exp_ib_dX = deriv_exp_0_d0*(d_Lc_IBB_Vib_dX);
exp_ib = value_exp_0;
}
d_isub_dX = ((IBA_IBB*Vib)*d_exp_ib_dX+(IBA_IBB*d_Vib_dX+d_IBA_IBB_dX*Vib)*exp_ib);
isub = ((IBA_IBB*Vib)*exp_ib);
d_Isub_dX = (isub*d_Id_dX+d_isub_dX*Id);
Isub = (isub*Id);
d_dIsub_factor_dX = ((Isub*inv_Vib)*(-d_Lc_IBB_Vib_dX)+(Isub*d_inv_Vib_dX+d_Isub_dX*inv_Vib)*(1.0-Lc_IBB_Vib));
dIsub_factor = ((Isub*inv_Vib)*(1.0-Lc_IBB_Vib));
}
else
{
d_Lc_IBB_Vib_dX = 0.0;
Lc_IBB_Vib = 0.0;
d_Isub_dX = 0.0;
Isub = 0.0;
}
d_Ibd_dX = (d_Ibd_dX-d_Isub_dX);
Ibd = (Ibd-Isub);
d_WLCox_dX = ((Weff*Leff)*modelStruct.d_modelPar_COX_dX+(Weff*d_Leff_dX+d_Weff_dX*Leff)*modelStruct.modelPar_COX);
WLCox = ((Weff*Leff)*modelStruct.modelPar_COX);
d_sif3_dX = (sif*d_sif2_dX+d_sif_dX*sif2);
sif3 = (sif*sif2);
d_sir3_dX = (sir*d_sir2_dX+d_sir_dX*sir2);
sir3 = (sir*sir2);
{
double value_sqrt_0 = sqrt((PHI_T+(0.5*VP)));
double  deriv_sqrt_0_d0 = (0.5/value_sqrt_0);
d_tmp1_dX = deriv_sqrt_0_d0*((d_PHI_T_dX+0.5*d_VP_dX));
tmp1 = value_sqrt_0;
}
d_sqrt_PHI_VP2_2_dX = (d_tmp1_dX+d_tmp1_dX);
sqrt_PHI_VP2_2 = (tmp1+tmp1);
d_n_Vt_COX_dX = (((1.0+(GAMMAprime/sqrt_PHI_VP2_2))*Vt)*d_WLCox_dX+((1.0+(GAMMAprime/sqrt_PHI_VP2_2))*d_Vt_dX+((sqrt_PHI_VP2_2*d_GAMMAprime_dX-GAMMAprime*d_sqrt_PHI_VP2_2_dX)/sqrt_PHI_VP2_2/sqrt_PHI_VP2_2)*Vt)*WLCox);
n_Vt_COX = (((1.0+(GAMMAprime/sqrt_PHI_VP2_2))*Vt)*WLCox);
d_QD_dX = ((-n_Vt_COX)*((sif_sir_2*0.266666666*(((3.0*d_sir3_dX+((6.0*sir2)*d_sif_dX+6.0*d_sir2_dX*sif))+((4.0*sir)*d_sif2_dX+4.0*d_sir_dX*sif2))+2.0*d_sif3_dX)-(0.266666666*((((3.0*sir3)+((6.0*sir2)*sif))+((4.0*sir)*sif2))+(2.0*sif3)))*d_sif_sir_2_dX)/sif_sir_2/sif_sir_2)+(-d_n_Vt_COX_dX)*(((0.266666666*((((3.0*sir3)+((6.0*sir2)*sif))+((4.0*sir)*sif2))+(2.0*sif3)))/sif_sir_2)-0.5));
QD = ((-n_Vt_COX)*(((0.266666666*((((3.0*sir3)+((6.0*sir2)*sif))+((4.0*sir)*sif2))+(2.0*sif3)))/sif_sir_2)-0.5));
d_QS_dX = ((-n_Vt_COX)*((sif_sir_2*0.266666666*(((3.0*d_sif3_dX+((6.0*sif2)*d_sir_dX+6.0*d_sif2_dX*sir))+((4.0*sif)*d_sir2_dX+4.0*d_sif_dX*sir2))+2.0*d_sir3_dX)-(0.266666666*((((3.0*sif3)+((6.0*sif2)*sir))+((4.0*sif)*sir2))+(2.0*sir3)))*d_sif_sir_2_dX)/sif_sir_2/sif_sir_2)+(-d_n_Vt_COX_dX)*(((0.266666666*((((3.0*sif3)+((6.0*sif2)*sir))+((4.0*sif)*sir2))+(2.0*sir3)))/sif_sir_2)-0.5));
QS = ((-n_Vt_COX)*(((0.266666666*((((3.0*sif3)+((6.0*sif2)*sir))+((4.0*sif)*sir2))+(2.0*sir3)))/sif_sir_2)-0.5));
d_QI_dX = (d_QS_dX+d_QD_dX);
QI = (QS+QD);
d_QB_dX = ((WLCox*(((((-0.5)*GAMMAprime)*d_sqrt_PHI_VP_2_dX+(-0.5)*d_GAMMAprime_dX*sqrt_PHI_VP_2)+d_VGprime_dX)-d_VGstar_dX)+d_WLCox_dX*(((((-0.5)*GAMMAprime)*sqrt_PHI_VP_2)+VGprime)-VGstar))-(((GAMMAprime+sqrt_PHI_VP2_2)*(QI*d_GAMMAprime_dX+d_QI_dX*GAMMAprime)-(QI*GAMMAprime)*(d_GAMMAprime_dX+d_sqrt_PHI_VP2_2_dX))/(GAMMAprime+sqrt_PHI_VP2_2)/(GAMMAprime+sqrt_PHI_VP2_2)));
QB = ((WLCox*(((((-0.5)*GAMMAprime)*sqrt_PHI_VP_2)+VGprime)-VGstar))-((QI*GAMMAprime)/(GAMMAprime+sqrt_PHI_VP2_2)));
d_QG_dX = ((-d_QI_dX)-d_QB_dX);
QG = ((-QI)-QB);
// I(d,s) <+ (((TYPE*Mode)*Id))
d_staticContributions_dX[admsNodeID_d]+= (modelStruct.modelPar_TYPE*Mode)*d_Id_dX;
d_staticContributions_dX[(admsNodeID_s)]-= (modelStruct.modelPar_TYPE*Mode)*d_Id_dX;
d_ddt_QD_dX = (d_QD_dX);
ddt_QD = (QD);
d_ddt_QS_dX = (d_QS_dX);
ddt_QS = (QS);
if ((Mode==1))
{
// I(d,b) <+ ((TYPE*ddt_QD))
d_staticContributions_dX[admsNodeID_d]+= modelStruct.modelPar_TYPE*d_ddt_QD_dX;
d_staticContributions_dX[(admsNodeID_b)]-= modelStruct.modelPar_TYPE*d_ddt_QD_dX;
// I(s,b) <+ ((TYPE*ddt_QS))
d_staticContributions_dX[admsNodeID_s]+= modelStruct.modelPar_TYPE*d_ddt_QS_dX;
d_staticContributions_dX[(admsNodeID_b)]-= modelStruct.modelPar_TYPE*d_ddt_QS_dX;
// I(d,b) <+ ((TYPE*Isub))
d_staticContributions_dX[admsNodeID_d]+= modelStruct.modelPar_TYPE*d_Isub_dX;
d_staticContributions_dX[(admsNodeID_b)]-= modelStruct.modelPar_TYPE*d_Isub_dX;
}
else
{
// I(s,b) <+ ((TYPE*ddt_QD))
d_staticContributions_dX[admsNodeID_s]+= modelStruct.modelPar_TYPE*d_ddt_QD_dX;
d_staticContributions_dX[(admsNodeID_b)]-= modelStruct.modelPar_TYPE*d_ddt_QD_dX;
// I(d,b) <+ ((TYPE*ddt_QS))
d_staticContributions_dX[admsNodeID_d]+= modelStruct.modelPar_TYPE*d_ddt_QS_dX;
d_staticContributions_dX[(admsNodeID_b)]-= modelStruct.modelPar_TYPE*d_ddt_QS_dX;
// I(s,b) <+ ((TYPE*Isub))
d_staticContributions_dX[admsNodeID_s]+= modelStruct.modelPar_TYPE*d_Isub_dX;
d_staticContributions_dX[(admsNodeID_b)]-= modelStruct.modelPar_TYPE*d_Isub_dX;
}
// I(g,b) <+ ((TYPE*ddt(QG)))
d_dynamicContributions_dX[admsNodeID_g]+= modelStruct.modelPar_TYPE*(d_QG_dX);
d_dynamicContributions_dX[(admsNodeID_b)]-= modelStruct.modelPar_TYPE*(d_QG_dX);
if (modelStruct.modelPar_Noise)
//Begin block Noise_block
{
//Block-local variables for block Noise_block
double S_flicker=0.0;
double d_S_flicker_dX=0.0;
double S_thermal=0.0;
double d_S_thermal_dX=0.0;
//End of Block-local variables
d_S_thermal_dX = (((4*1.3806226e-23)*T)*d_Gn_dX+(4*1.3806226e-23)*d_T_dX*Gn);
S_thermal = (((4*1.3806226e-23)*T)*Gn);
d_S_flicker_dX = (((((Weff*instanceStruct.instancePar_NS)*Leff)*modelStruct.modelPar_COX)*((modelStruct.modelPar_KF*gm)*d_gm_dX+(modelStruct.modelPar_KF*d_gm_dX+modelStruct.d_modelPar_KF_dX*gm)*gm)-((modelStruct.modelPar_KF*gm)*gm)*(((Weff*instanceStruct.instancePar_NS)*Leff)*modelStruct.d_modelPar_COX_dX+((Weff*instanceStruct.instancePar_NS)*d_Leff_dX+(Weff*instanceStruct.d_instancePar_NS_dX+d_Weff_dX*instanceStruct.instancePar_NS)*Leff)*modelStruct.modelPar_COX))/(((Weff*instanceStruct.instancePar_NS)*Leff)*modelStruct.modelPar_COX)/(((Weff*instanceStruct.instancePar_NS)*Leff)*modelStruct.modelPar_COX));
S_flicker = (((modelStruct.modelPar_KF*gm)*gm)/(((Weff*instanceStruct.instancePar_NS)*Leff)*modelStruct.modelPar_COX));
// I(d,s) <+ (white_noise(S_thermal,"thermal"))
// I(d,s) <+ (flicker_noise(S_flicker,AF,"flicker"))
}
// End block Noise_block
if (((instanceStruct.instancePar_AS==0.0)&&(modelStruct.modelPar_HDIF>0.0)))
{
d_as_i_dX = ((2.0*modelStruct.modelPar_HDIF)*d_Weff_dX+2.0*modelStruct.d_modelPar_HDIF_dX*Weff);
as_i = ((2.0*modelStruct.modelPar_HDIF)*Weff);
}
else
{
d_as_i_dX = instanceStruct.d_instancePar_AS_dX;
as_i = instanceStruct.instancePar_AS;
}
if (((instanceStruct.instancePar_PS==0.0)&&(modelStruct.modelPar_HDIF>0.0)))
{
d_ps_i_dX = (4.0*modelStruct.d_modelPar_HDIF_dX+1.0*d_Weff_dX);
ps_i = ((4.0*modelStruct.modelPar_HDIF)+(1.0*Weff));
}
else
{
d_ps_i_dX = instanceStruct.d_instancePar_PS_dX;
ps_i = instanceStruct.instancePar_PS;
}
if (((instanceStruct.instancePar_AD==0.0)&&(modelStruct.modelPar_HDIF>0.0)))
{
d_ad_i_dX = ((2.0*modelStruct.modelPar_HDIF)*d_Weff_dX+2.0*modelStruct.d_modelPar_HDIF_dX*Weff);
ad_i = ((2.0*modelStruct.modelPar_HDIF)*Weff);
}
else
{
d_ad_i_dX = instanceStruct.d_instancePar_AD_dX;
ad_i = instanceStruct.instancePar_AD;
}
if (((instanceStruct.instancePar_PD==0.0)&&(modelStruct.modelPar_HDIF>0.0)))
{
d_pd_i_dX = (4.0*modelStruct.d_modelPar_HDIF_dX+1.0*d_Weff_dX);
pd_i = ((4.0*modelStruct.modelPar_HDIF)+(1.0*Weff));
}
else
{
d_pd_i_dX = instanceStruct.d_instancePar_PD_dX;
pd_i = instanceStruct.instancePar_PD;
}
{
double value_log_0 = log(ratioT);
double value_exp_1 = exp(((((refEg/adms_vt(Tnom))-(Eg/Vt))+(modelStruct.modelPar_tp_xti*value_log_0))/modelStruct.modelPar_xd_n));
double  deriv_log_0_d0 = (1.0/ratioT);
double  deriv_exp_1_d0 = value_exp_1;
d_temp_arg_dX = deriv_exp_1_d0*(((modelStruct.modelPar_xd_n*(((d_refEg_dX/adms_vt(Tnom))-((Vt*d_Eg_dX-Eg*d_Vt_dX)/Vt/Vt))+(modelStruct.modelPar_tp_xti*deriv_log_0_d0*(d_ratioT_dX)+modelStruct.d_modelPar_tp_xti_dX*value_log_0))-(((refEg/adms_vt(Tnom))-(Eg/Vt))+(modelStruct.modelPar_tp_xti*value_log_0))*modelStruct.d_modelPar_xd_n_dX)/modelStruct.modelPar_xd_n/modelStruct.modelPar_xd_n));
temp_arg = value_exp_1;
}
d_js_t_dX = (modelStruct.modelPar_xd_js*d_temp_arg_dX+modelStruct.d_modelPar_xd_js_dX*temp_arg);
js_t = (modelStruct.modelPar_xd_js*temp_arg);
d_jsw_t_dX = (modelStruct.modelPar_xd_jsw*d_temp_arg_dX+modelStruct.d_modelPar_xd_jsw_dX*temp_arg);
jsw_t = (modelStruct.modelPar_xd_jsw*temp_arg);
d_jswg_t_dX = (modelStruct.modelPar_xd_jswg*d_temp_arg_dX+modelStruct.d_modelPar_xd_jswg_dX*temp_arg);
jswg_t = (modelStruct.modelPar_xd_jswg*temp_arg);
d_pb_t_dX = (modelStruct.d_modelPar_xd_pb_dX-(modelStruct.modelPar_tp_pb*d_deltaT_dX+modelStruct.d_modelPar_tp_pb_dX*deltaT));
pb_t = (modelStruct.modelPar_xd_pb-(modelStruct.modelPar_tp_pb*deltaT));
d_pbsw_t_dX = (modelStruct.d_modelPar_xd_pbsw_dX-(modelStruct.modelPar_tp_pbsw*d_deltaT_dX+modelStruct.d_modelPar_tp_pbsw_dX*deltaT));
pbsw_t = (modelStruct.modelPar_xd_pbsw-(modelStruct.modelPar_tp_pbsw*deltaT));
d_pbswg_t_dX = (modelStruct.d_modelPar_xd_pbswg_dX-(modelStruct.modelPar_tp_pbswg*d_deltaT_dX+modelStruct.d_modelPar_tp_pbswg_dX*deltaT));
pbswg_t = (modelStruct.modelPar_xd_pbswg-(modelStruct.modelPar_tp_pbswg*deltaT));
d_cj_t_dX = (modelStruct.modelPar_xd_cj*(modelStruct.modelPar_tp_cj*d_deltaT_dX+modelStruct.d_modelPar_tp_cj_dX*deltaT)+modelStruct.d_modelPar_xd_cj_dX*(1.0+(modelStruct.modelPar_tp_cj*deltaT)));
cj_t = (modelStruct.modelPar_xd_cj*(1.0+(modelStruct.modelPar_tp_cj*deltaT)));
d_cjsw_t_dX = (modelStruct.modelPar_xd_cjsw*(modelStruct.modelPar_tp_cjsw*d_deltaT_dX+modelStruct.d_modelPar_tp_cjsw_dX*deltaT)+modelStruct.d_modelPar_xd_cjsw_dX*(1.0+(modelStruct.modelPar_tp_cjsw*deltaT)));
cjsw_t = (modelStruct.modelPar_xd_cjsw*(1.0+(modelStruct.modelPar_tp_cjsw*deltaT)));
d_cjswg_t_dX = (modelStruct.modelPar_xd_cjswg*(modelStruct.modelPar_tp_cjswg*d_deltaT_dX+modelStruct.d_modelPar_tp_cjswg_dX*deltaT)+modelStruct.d_modelPar_xd_cjswg_dX*(1.0+(modelStruct.modelPar_tp_cjswg*deltaT)));
cjswg_t = (modelStruct.modelPar_xd_cjswg*(1.0+(modelStruct.modelPar_tp_cjswg*deltaT)));
d_njts_t_dX = (modelStruct.modelPar_xd_njts*((ratioT-1.0)*modelStruct.d_modelPar_tp_njts_dX+d_ratioT_dX*modelStruct.modelPar_tp_njts)+modelStruct.d_modelPar_xd_njts_dX*(1.0+((ratioT-1.0)*modelStruct.modelPar_tp_njts)));
njts_t = (modelStruct.modelPar_xd_njts*(1.0+((ratioT-1.0)*modelStruct.modelPar_tp_njts)));
d_njtssw_t_dX = (modelStruct.modelPar_xd_njtssw*((ratioT-1.0)*modelStruct.d_modelPar_tp_njtssw_dX+d_ratioT_dX*modelStruct.modelPar_tp_njtssw)+modelStruct.d_modelPar_xd_njtssw_dX*(1.0+((ratioT-1.0)*modelStruct.modelPar_tp_njtssw)));
njtssw_t = (modelStruct.modelPar_xd_njtssw*(1.0+((ratioT-1.0)*modelStruct.modelPar_tp_njtssw)));
d_njtsswg_t_dX = (modelStruct.modelPar_xd_njtsswg*((ratioT-1.0)*modelStruct.d_modelPar_tp_njtsswg_dX+d_ratioT_dX*modelStruct.modelPar_tp_njtsswg)+modelStruct.d_modelPar_xd_njtsswg_dX*(1.0+((ratioT-1.0)*modelStruct.modelPar_tp_njtsswg)));
njtsswg_t = (modelStruct.modelPar_xd_njtsswg*(1.0+((ratioT-1.0)*modelStruct.modelPar_tp_njtsswg)));
d_v_di_b_dX = 0.0;
v_di_b = (modelStruct.modelPar_TYPE*(probeVars[admsProbeID_V_d_b]));
d_v_si_b_dX = 0.0;
v_si_b = (modelStruct.modelPar_TYPE*(probeVars[admsProbeID_V_s_b]));
d_is_d_dX = (((js_t*d_ad_i_dX+d_js_t_dX*ad_i)+(jsw_t*d_pd_i_dX+d_jsw_t_dX*pd_i))+(jswg_t*d_Weff_dX+d_jswg_t_dX*Weff));
is_d = (((js_t*ad_i)+(jsw_t*pd_i))+(jswg_t*Weff));
d_arg_d_dX = (((Vt*modelStruct.modelPar_xd_n)*((-v_di_b)*d_ratioT_dX+(-d_v_di_b_dX)*ratioT)-((-v_di_b)*ratioT)*(Vt*modelStruct.d_modelPar_xd_n_dX+d_Vt_dX*modelStruct.modelPar_xd_n))/(Vt*modelStruct.modelPar_xd_n)/(Vt*modelStruct.modelPar_xd_n));
arg_d = (((-v_di_b)*ratioT)/(Vt*modelStruct.modelPar_xd_n));
if ((arg_d<(-40.0)))
{
d_arg_d_dX = 0.0;
arg_d = (-40.0);
}
d_tmp0_dX = (((Vt*modelStruct.modelPar_xd_n)*(((-v_di_b)+modelStruct.modelPar_xd_bv)*d_ratioT_dX+((-d_v_di_b_dX)+modelStruct.d_modelPar_xd_bv_dX)*ratioT)-(((-v_di_b)+modelStruct.modelPar_xd_bv)*ratioT)*(Vt*modelStruct.d_modelPar_xd_n_dX+d_Vt_dX*modelStruct.modelPar_xd_n))/(Vt*modelStruct.modelPar_xd_n)/(Vt*modelStruct.modelPar_xd_n));
tmp0 = ((((-v_di_b)+modelStruct.modelPar_xd_bv)*ratioT)/(Vt*modelStruct.modelPar_xd_n));
if ((tmp0>70))
{
d_f_breakdown_d_dX = 0.0;
f_breakdown_d = 1.0;
}
else
{
{
double value_exp_0 = exp((-tmp0));
double  deriv_exp_0_d0 = value_exp_0;
d_f_breakdown_d_dX = (modelStruct.modelPar_xd_xjbv*deriv_exp_0_d0*((-d_tmp0_dX))+modelStruct.d_modelPar_xd_xjbv_dX*value_exp_0);
f_breakdown_d = (1.0+(modelStruct.modelPar_xd_xjbv*value_exp_0));
}
}
{
double value_max_0 = std::max((modelStruct.modelPar_xd_vtsswg+v_di_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_di_b*ratioT)/(Vt*njtsswg_t))*modelStruct.modelPar_xd_vtsswg)/value_max_0));
double  deriv_max_0_d0 = (((modelStruct.modelPar_xd_vtsswg+v_di_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;
d_idb_tun_dX = (((-Weff)*jswg_t)*deriv_exp_1_d0*(((value_max_0*(((v_di_b*ratioT)/(Vt*njtsswg_t))*modelStruct.d_modelPar_xd_vtsswg_dX+(((Vt*njtsswg_t)*(v_di_b*d_ratioT_dX+d_v_di_b_dX*ratioT)-(v_di_b*ratioT)*(Vt*d_njtsswg_t_dX+d_Vt_dX*njtsswg_t))/(Vt*njtsswg_t)/(Vt*njtsswg_t))*modelStruct.modelPar_xd_vtsswg)-(((v_di_b*ratioT)/(Vt*njtsswg_t))*modelStruct.modelPar_xd_vtsswg)*(deriv_max_0_d0*((modelStruct.d_modelPar_xd_vtsswg_dX+d_v_di_b_dX))))/value_max_0/value_max_0))+((-Weff)*d_jswg_t_dX+(-d_Weff_dX)*jswg_t)*(value_exp_1-1.0));
idb_tun = (((-Weff)*jswg_t)*(value_exp_1-1.0));
}
{
double value_max_0 = std::max((modelStruct.modelPar_xd_vtssw+v_di_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_di_b*ratioT)/(Vt*njtssw_t))*modelStruct.modelPar_xd_vtssw)/value_max_0));
double  deriv_max_0_d0 = (((modelStruct.modelPar_xd_vtssw+v_di_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;
d_idb_tun_dX = (d_idb_tun_dX-((pd_i*jsw_t)*deriv_exp_1_d0*(((value_max_0*(((v_di_b*ratioT)/(Vt*njtssw_t))*modelStruct.d_modelPar_xd_vtssw_dX+(((Vt*njtssw_t)*(v_di_b*d_ratioT_dX+d_v_di_b_dX*ratioT)-(v_di_b*ratioT)*(Vt*d_njtssw_t_dX+d_Vt_dX*njtssw_t))/(Vt*njtssw_t)/(Vt*njtssw_t))*modelStruct.modelPar_xd_vtssw)-(((v_di_b*ratioT)/(Vt*njtssw_t))*modelStruct.modelPar_xd_vtssw)*(deriv_max_0_d0*((modelStruct.d_modelPar_xd_vtssw_dX+d_v_di_b_dX))))/value_max_0/value_max_0))+(pd_i*d_jsw_t_dX+d_pd_i_dX*jsw_t)*(value_exp_1-1.0)));
idb_tun = (idb_tun-((pd_i*jsw_t)*(value_exp_1-1.0)));
}
{
double value_max_0 = std::max((modelStruct.modelPar_xd_vts+v_di_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_di_b*ratioT)/(Vt*njts_t))*modelStruct.modelPar_xd_vts)/value_max_0));
double  deriv_max_0_d0 = (((modelStruct.modelPar_xd_vts+v_di_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;
d_idb_tun_dX = (d_idb_tun_dX-((ad_i*js_t)*deriv_exp_1_d0*(((value_max_0*(((v_di_b*ratioT)/(Vt*njts_t))*modelStruct.d_modelPar_xd_vts_dX+(((Vt*njts_t)*(v_di_b*d_ratioT_dX+d_v_di_b_dX*ratioT)-(v_di_b*ratioT)*(Vt*d_njts_t_dX+d_Vt_dX*njts_t))/(Vt*njts_t)/(Vt*njts_t))*modelStruct.modelPar_xd_vts)-(((v_di_b*ratioT)/(Vt*njts_t))*modelStruct.modelPar_xd_vts)*(deriv_max_0_d0*((modelStruct.d_modelPar_xd_vts_dX+d_v_di_b_dX))))/value_max_0/value_max_0))+(ad_i*d_js_t_dX+d_ad_i_dX*js_t)*(value_exp_1-1.0)));
idb_tun = (idb_tun-((ad_i*js_t)*(value_exp_1-1.0)));
}
// I(d,b) <+ (((((((is_d*(1.0-exp(arg_d)))*f_breakdown_d)+(v_di_b*xd_gmin))+idb_tun)*TYPE)*M))
{
double value_exp_0 = exp(arg_d);
double  deriv_exp_0_d0 = value_exp_0;
d_staticContributions_dX[admsNodeID_d]+= ((((((is_d*(1.0-value_exp_0))*f_breakdown_d)+(v_di_b*modelStruct.modelPar_xd_gmin))+idb_tun)*modelStruct.modelPar_TYPE)*instanceStruct.d_instancePar_M_dX+((((is_d*(1.0-value_exp_0))*d_f_breakdown_d_dX+(is_d*(-deriv_exp_0_d0*(d_arg_d_dX))+d_is_d_dX*(1.0-value_exp_0))*f_breakdown_d)+(v_di_b*modelStruct.d_modelPar_xd_gmin_dX+d_v_di_b_dX*modelStruct.modelPar_xd_gmin))+d_idb_tun_dX)*modelStruct.modelPar_TYPE*instanceStruct.instancePar_M);
d_staticContributions_dX[(admsNodeID_b)]-= ((((((is_d*(1.0-value_exp_0))*f_breakdown_d)+(v_di_b*modelStruct.modelPar_xd_gmin))+idb_tun)*modelStruct.modelPar_TYPE)*instanceStruct.d_instancePar_M_dX+((((is_d*(1.0-value_exp_0))*d_f_breakdown_d_dX+(is_d*(-deriv_exp_0_d0*(d_arg_d_dX))+d_is_d_dX*(1.0-value_exp_0))*f_breakdown_d)+(v_di_b*modelStruct.d_modelPar_xd_gmin_dX+d_v_di_b_dX*modelStruct.modelPar_xd_gmin))+d_idb_tun_dX)*modelStruct.modelPar_TYPE*instanceStruct.instancePar_M);
}
d_is_s_dX = (((js_t*d_as_i_dX+d_js_t_dX*as_i)+(jsw_t*d_ps_i_dX+d_jsw_t_dX*ps_i))+(jswg_t*d_Weff_dX+d_jswg_t_dX*Weff));
is_s = (((js_t*as_i)+(jsw_t*ps_i))+(jswg_t*Weff));
d_arg_s_dX = (((Vt*modelStruct.modelPar_xd_n)*((-v_si_b)*d_ratioT_dX+(-d_v_si_b_dX)*ratioT)-((-v_si_b)*ratioT)*(Vt*modelStruct.d_modelPar_xd_n_dX+d_Vt_dX*modelStruct.modelPar_xd_n))/(Vt*modelStruct.modelPar_xd_n)/(Vt*modelStruct.modelPar_xd_n));
arg_s = (((-v_si_b)*ratioT)/(Vt*modelStruct.modelPar_xd_n));
if ((arg_s<(-40.0)))
{
d_arg_s_dX = 0.0;
arg_s = (-40.0);
}
d_tmp0_dX = (((Vt*modelStruct.modelPar_xd_n)*(((-v_si_b)+modelStruct.modelPar_xd_bv)*d_ratioT_dX+((-d_v_si_b_dX)+modelStruct.d_modelPar_xd_bv_dX)*ratioT)-(((-v_si_b)+modelStruct.modelPar_xd_bv)*ratioT)*(Vt*modelStruct.d_modelPar_xd_n_dX+d_Vt_dX*modelStruct.modelPar_xd_n))/(Vt*modelStruct.modelPar_xd_n)/(Vt*modelStruct.modelPar_xd_n));
tmp0 = ((((-v_si_b)+modelStruct.modelPar_xd_bv)*ratioT)/(Vt*modelStruct.modelPar_xd_n));
if ((tmp0>70))
{
d_f_breakdown_s_dX = 0.0;
f_breakdown_s = 1.0;
}
else
{
{
double value_exp_0 = exp((-tmp0));
double  deriv_exp_0_d0 = value_exp_0;
d_f_breakdown_s_dX = (modelStruct.modelPar_xd_xjbv*deriv_exp_0_d0*((-d_tmp0_dX))+modelStruct.d_modelPar_xd_xjbv_dX*value_exp_0);
f_breakdown_s = (1.0+(modelStruct.modelPar_xd_xjbv*value_exp_0));
}
}
{
double value_max_0 = std::max((modelStruct.modelPar_xd_vtsswg+v_si_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_si_b*ratioT)/(Vt*njtsswg_t))*modelStruct.modelPar_xd_vtsswg)/value_max_0));
double  deriv_max_0_d0 = (((modelStruct.modelPar_xd_vtsswg+v_si_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;
d_isb_tun_dX = (((-Weff)*jswg_t)*deriv_exp_1_d0*(((value_max_0*(((v_si_b*ratioT)/(Vt*njtsswg_t))*modelStruct.d_modelPar_xd_vtsswg_dX+(((Vt*njtsswg_t)*(v_si_b*d_ratioT_dX+d_v_si_b_dX*ratioT)-(v_si_b*ratioT)*(Vt*d_njtsswg_t_dX+d_Vt_dX*njtsswg_t))/(Vt*njtsswg_t)/(Vt*njtsswg_t))*modelStruct.modelPar_xd_vtsswg)-(((v_si_b*ratioT)/(Vt*njtsswg_t))*modelStruct.modelPar_xd_vtsswg)*(deriv_max_0_d0*((modelStruct.d_modelPar_xd_vtsswg_dX+d_v_si_b_dX))))/value_max_0/value_max_0))+((-Weff)*d_jswg_t_dX+(-d_Weff_dX)*jswg_t)*(value_exp_1-1.0));
isb_tun = (((-Weff)*jswg_t)*(value_exp_1-1.0));
}
{
double value_max_0 = std::max((modelStruct.modelPar_xd_vtssw+v_si_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_si_b*ratioT)/(Vt*njtssw_t))*modelStruct.modelPar_xd_vtssw)/value_max_0));
double  deriv_max_0_d0 = (((modelStruct.modelPar_xd_vtssw+v_si_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;
d_isb_tun_dX = (d_isb_tun_dX-((ps_i*jsw_t)*deriv_exp_1_d0*(((value_max_0*(((v_si_b*ratioT)/(Vt*njtssw_t))*modelStruct.d_modelPar_xd_vtssw_dX+(((Vt*njtssw_t)*(v_si_b*d_ratioT_dX+d_v_si_b_dX*ratioT)-(v_si_b*ratioT)*(Vt*d_njtssw_t_dX+d_Vt_dX*njtssw_t))/(Vt*njtssw_t)/(Vt*njtssw_t))*modelStruct.modelPar_xd_vtssw)-(((v_si_b*ratioT)/(Vt*njtssw_t))*modelStruct.modelPar_xd_vtssw)*(deriv_max_0_d0*((modelStruct.d_modelPar_xd_vtssw_dX+d_v_si_b_dX))))/value_max_0/value_max_0))+(ps_i*d_jsw_t_dX+d_ps_i_dX*jsw_t)*(value_exp_1-1.0)));
isb_tun = (isb_tun-((ps_i*jsw_t)*(value_exp_1-1.0)));
}
{
double value_max_0 = std::max((modelStruct.modelPar_xd_vts+v_si_b),static_cast<double>(1.0e-3));
double value_exp_1 = exp(((((v_si_b*ratioT)/(Vt*njts_t))*modelStruct.modelPar_xd_vts)/value_max_0));
double  deriv_max_0_d0 = (((modelStruct.modelPar_xd_vts+v_si_b)>=1.0e-3)?1.0:0.0);
double  deriv_exp_1_d0 = value_exp_1;
d_isb_tun_dX = (d_isb_tun_dX-((as_i*js_t)*deriv_exp_1_d0*(((value_max_0*(((v_si_b*ratioT)/(Vt*njts_t))*modelStruct.d_modelPar_xd_vts_dX+(((Vt*njts_t)*(v_si_b*d_ratioT_dX+d_v_si_b_dX*ratioT)-(v_si_b*ratioT)*(Vt*d_njts_t_dX+d_Vt_dX*njts_t))/(Vt*njts_t)/(Vt*njts_t))*modelStruct.modelPar_xd_vts)-(((v_si_b*ratioT)/(Vt*njts_t))*modelStruct.modelPar_xd_vts)*(deriv_max_0_d0*((modelStruct.d_modelPar_xd_vts_dX+d_v_si_b_dX))))/value_max_0/value_max_0))+(as_i*d_js_t_dX+d_as_i_dX*js_t)*(value_exp_1-1.0)));
isb_tun = (isb_tun-((as_i*js_t)*(value_exp_1-1.0)));
}
// I(s,b) <+ (((((((is_s*(1.0-exp(arg_s)))*f_breakdown_s)+(v_si_b*xd_gmin))+isb_tun)*TYPE)*M))
{
double value_exp_0 = exp(arg_s);
double  deriv_exp_0_d0 = value_exp_0;
d_staticContributions_dX[admsNodeID_s]+= ((((((is_s*(1.0-value_exp_0))*f_breakdown_s)+(v_si_b*modelStruct.modelPar_xd_gmin))+isb_tun)*modelStruct.modelPar_TYPE)*instanceStruct.d_instancePar_M_dX+((((is_s*(1.0-value_exp_0))*d_f_breakdown_s_dX+(is_s*(-deriv_exp_0_d0*(d_arg_s_dX))+d_is_s_dX*(1.0-value_exp_0))*f_breakdown_s)+(v_si_b*modelStruct.d_modelPar_xd_gmin_dX+d_v_si_b_dX*modelStruct.modelPar_xd_gmin))+d_isb_tun_dX)*modelStruct.modelPar_TYPE*instanceStruct.instancePar_M);
d_staticContributions_dX[(admsNodeID_b)]-= ((((((is_s*(1.0-value_exp_0))*f_breakdown_s)+(v_si_b*modelStruct.modelPar_xd_gmin))+isb_tun)*modelStruct.modelPar_TYPE)*instanceStruct.d_instancePar_M_dX+((((is_s*(1.0-value_exp_0))*d_f_breakdown_s_dX+(is_s*(-deriv_exp_0_d0*(d_arg_s_dX))+d_is_s_dX*(1.0-value_exp_0))*f_breakdown_s)+(v_si_b*modelStruct.d_modelPar_xd_gmin_dX+d_v_si_b_dX*modelStruct.modelPar_xd_gmin))+d_isb_tun_dX)*modelStruct.modelPar_TYPE*instanceStruct.instancePar_M);
}
if ((v_di_b>0.0))
{
{
double value_log_0 = log((1.0+(v_di_b/pb_t)));
double value_exp_1 = exp(((-modelStruct.modelPar_xd_mj)*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_di_b/pb_t)));
double  deriv_exp_1_d0 = value_exp_1;
d_csb_d_dX = ((cj_t*ad_i)*deriv_exp_1_d0*(((-modelStruct.modelPar_xd_mj)*deriv_log_0_d0*(((pb_t*d_v_di_b_dX-v_di_b*d_pb_t_dX)/pb_t/pb_t))+(-modelStruct.d_modelPar_xd_mj_dX)*value_log_0))+(cj_t*d_ad_i_dX+d_cj_t_dX*ad_i)*value_exp_1);
csb_d = ((cj_t*ad_i)*value_exp_1);
}
{
double value_log_0 = log((1.0+(v_di_b/pbsw_t)));
double value_exp_1 = exp(((-modelStruct.modelPar_xd_mjsw)*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_di_b/pbsw_t)));
double  deriv_exp_1_d0 = value_exp_1;
d_cssw_d_dX = ((cjsw_t*pd_i)*deriv_exp_1_d0*(((-modelStruct.modelPar_xd_mjsw)*deriv_log_0_d0*(((pbsw_t*d_v_di_b_dX-v_di_b*d_pbsw_t_dX)/pbsw_t/pbsw_t))+(-modelStruct.d_modelPar_xd_mjsw_dX)*value_log_0))+(cjsw_t*d_pd_i_dX+d_cjsw_t_dX*pd_i)*value_exp_1);
cssw_d = ((cjsw_t*pd_i)*value_exp_1);
}
{
double value_log_0 = log((1.0+(v_di_b/pbswg_t)));
double value_exp_1 = exp(((-modelStruct.modelPar_xd_mjswg)*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_di_b/pbswg_t)));
double  deriv_exp_1_d0 = value_exp_1;
d_csswg_d_dX = ((cjswg_t*Weff)*deriv_exp_1_d0*(((-modelStruct.modelPar_xd_mjswg)*deriv_log_0_d0*(((pbswg_t*d_v_di_b_dX-v_di_b*d_pbswg_t_dX)/pbswg_t/pbswg_t))+(-modelStruct.d_modelPar_xd_mjswg_dX)*value_log_0))+(cjswg_t*d_Weff_dX+d_cjswg_t_dX*Weff)*value_exp_1);
csswg_d = ((cjswg_t*Weff)*value_exp_1);
}
}
else
{
d_csb_d_dX = ((cj_t*ad_i)*(-((pb_t*(modelStruct.modelPar_xd_mj*d_v_di_b_dX+modelStruct.d_modelPar_xd_mj_dX*v_di_b)-(modelStruct.modelPar_xd_mj*v_di_b)*d_pb_t_dX)/pb_t/pb_t))+(cj_t*d_ad_i_dX+d_cj_t_dX*ad_i)*(1.0-((modelStruct.modelPar_xd_mj*v_di_b)/pb_t)));
csb_d = ((cj_t*ad_i)*(1.0-((modelStruct.modelPar_xd_mj*v_di_b)/pb_t)));
d_cssw_d_dX = ((cjsw_t*pd_i)*(-((pbsw_t*(modelStruct.modelPar_xd_mjsw*d_v_di_b_dX+modelStruct.d_modelPar_xd_mjsw_dX*v_di_b)-(modelStruct.modelPar_xd_mjsw*v_di_b)*d_pbsw_t_dX)/pbsw_t/pbsw_t))+(cjsw_t*d_pd_i_dX+d_cjsw_t_dX*pd_i)*(1.0-((modelStruct.modelPar_xd_mjsw*v_di_b)/pbsw_t)));
cssw_d = ((cjsw_t*pd_i)*(1.0-((modelStruct.modelPar_xd_mjsw*v_di_b)/pbsw_t)));
d_csswg_d_dX = ((cjswg_t*Weff)*(-((pbswg_t*(modelStruct.modelPar_xd_mjswg*d_v_di_b_dX+modelStruct.d_modelPar_xd_mjswg_dX*v_di_b)-(modelStruct.modelPar_xd_mjswg*v_di_b)*d_pbswg_t_dX)/pbswg_t/pbswg_t))+(cjswg_t*d_Weff_dX+d_cjswg_t_dX*Weff)*(1.0-((modelStruct.modelPar_xd_mjswg*v_di_b)/pbswg_t)));
csswg_d = ((cjswg_t*Weff)*(1.0-((modelStruct.modelPar_xd_mjswg*v_di_b)/pbswg_t)));
}
d_qjd_dX = (((csb_d+cssw_d)+csswg_d)*d_v_di_b_dX+((d_csb_d_dX+d_cssw_d_dX)+d_csswg_d_dX)*v_di_b);
qjd = (((csb_d+cssw_d)+csswg_d)*v_di_b);
// I(d,b) <+ (((ddt(qjd)*TYPE)*M))
d_dynamicContributions_dX[admsNodeID_d]+= (((qjd)*modelStruct.modelPar_TYPE)*instanceStruct.d_instancePar_M_dX+(d_qjd_dX)*modelStruct.modelPar_TYPE*instanceStruct.instancePar_M);
d_dynamicContributions_dX[(admsNodeID_b)]-= (((qjd)*modelStruct.modelPar_TYPE)*instanceStruct.d_instancePar_M_dX+(d_qjd_dX)*modelStruct.modelPar_TYPE*instanceStruct.instancePar_M);
if ((v_si_b>0.0))
{
{
double value_log_0 = log((1.0+(v_si_b/pb_t)));
double value_exp_1 = exp(((-modelStruct.modelPar_xd_mj)*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_si_b/pb_t)));
double  deriv_exp_1_d0 = value_exp_1;
d_csb_s_dX = ((cj_t*as_i)*deriv_exp_1_d0*(((-modelStruct.modelPar_xd_mj)*deriv_log_0_d0*(((pb_t*d_v_si_b_dX-v_si_b*d_pb_t_dX)/pb_t/pb_t))+(-modelStruct.d_modelPar_xd_mj_dX)*value_log_0))+(cj_t*d_as_i_dX+d_cj_t_dX*as_i)*value_exp_1);
csb_s = ((cj_t*as_i)*value_exp_1);
}
{
double value_log_0 = log((1.0+(v_si_b/pbsw_t)));
double value_exp_1 = exp(((-modelStruct.modelPar_xd_mjsw)*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_si_b/pbsw_t)));
double  deriv_exp_1_d0 = value_exp_1;
d_cssw_s_dX = ((cjsw_t*ps_i)*deriv_exp_1_d0*(((-modelStruct.modelPar_xd_mjsw)*deriv_log_0_d0*(((pbsw_t*d_v_si_b_dX-v_si_b*d_pbsw_t_dX)/pbsw_t/pbsw_t))+(-modelStruct.d_modelPar_xd_mjsw_dX)*value_log_0))+(cjsw_t*d_ps_i_dX+d_cjsw_t_dX*ps_i)*value_exp_1);
cssw_s = ((cjsw_t*ps_i)*value_exp_1);
}
{
double value_log_0 = log((1.0+(v_si_b/pbswg_t)));
double value_exp_1 = exp(((-modelStruct.modelPar_xd_mjswg)*value_log_0));
double  deriv_log_0_d0 = (1.0/(1.0+(v_si_b/pbswg_t)));
double  deriv_exp_1_d0 = value_exp_1;
d_csswg_s_dX = ((cjswg_t*Weff)*deriv_exp_1_d0*(((-modelStruct.modelPar_xd_mjswg)*deriv_log_0_d0*(((pbswg_t*d_v_si_b_dX-v_si_b*d_pbswg_t_dX)/pbswg_t/pbswg_t))+(-modelStruct.d_modelPar_xd_mjswg_dX)*value_log_0))+(cjswg_t*d_Weff_dX+d_cjswg_t_dX*Weff)*value_exp_1);
csswg_s = ((cjswg_t*Weff)*value_exp_1);
}
}
else
{
d_csb_s_dX = ((cj_t*as_i)*(-((pb_t*(modelStruct.modelPar_xd_mj*d_v_si_b_dX+modelStruct.d_modelPar_xd_mj_dX*v_si_b)-(modelStruct.modelPar_xd_mj*v_si_b)*d_pb_t_dX)/pb_t/pb_t))+(cj_t*d_as_i_dX+d_cj_t_dX*as_i)*(1.0-((modelStruct.modelPar_xd_mj*v_si_b)/pb_t)));
csb_s = ((cj_t*as_i)*(1.0-((modelStruct.modelPar_xd_mj*v_si_b)/pb_t)));
d_cssw_s_dX = ((cjsw_t*ps_i)*(-((pbsw_t*(modelStruct.modelPar_xd_mjsw*d_v_si_b_dX+modelStruct.d_modelPar_xd_mjsw_dX*v_si_b)-(modelStruct.modelPar_xd_mjsw*v_si_b)*d_pbsw_t_dX)/pbsw_t/pbsw_t))+(cjsw_t*d_ps_i_dX+d_cjsw_t_dX*ps_i)*(1.0-((modelStruct.modelPar_xd_mjsw*v_si_b)/pbsw_t)));
cssw_s = ((cjsw_t*ps_i)*(1.0-((modelStruct.modelPar_xd_mjsw*v_si_b)/pbsw_t)));
d_csswg_s_dX = ((cjswg_t*Weff)*(-((pbswg_t*(modelStruct.modelPar_xd_mjswg*d_v_si_b_dX+modelStruct.d_modelPar_xd_mjswg_dX*v_si_b)-(modelStruct.modelPar_xd_mjswg*v_si_b)*d_pbswg_t_dX)/pbswg_t/pbswg_t))+(cjswg_t*d_Weff_dX+d_cjswg_t_dX*Weff)*(1.0-((modelStruct.modelPar_xd_mjswg*v_si_b)/pbswg_t)));
csswg_s = ((cjswg_t*Weff)*(1.0-((modelStruct.modelPar_xd_mjswg*v_si_b)/pbswg_t)));
}
d_qjs_dX = (((csb_s+cssw_s)+csswg_s)*d_v_si_b_dX+((d_csb_s_dX+d_cssw_s_dX)+d_csswg_s_dX)*v_si_b);
qjs = (((csb_s+cssw_s)+csswg_s)*v_si_b);
// I(s,b) <+ (((ddt(qjs)*TYPE)*M))
d_dynamicContributions_dX[admsNodeID_s]+= (((qjs)*modelStruct.modelPar_TYPE)*instanceStruct.d_instancePar_M_dX+(d_qjs_dX)*modelStruct.modelPar_TYPE*instanceStruct.instancePar_M);
d_dynamicContributions_dX[(admsNodeID_b)]-= (((qjs)*modelStruct.modelPar_TYPE)*instanceStruct.d_instancePar_M_dX+(d_qjs_dX)*modelStruct.modelPar_TYPE*instanceStruct.instancePar_M);
}



//-----------------------------------------------------------------------------
// Function      : InstanceSensitivity::operator()
// Purpose       : return sensitivity for a single instance parameter
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
/// Compute sensitivity of a device instance's outputs to a specified instance
/// parameter
///
///
/// @param[in] entity  The device entity that owns the parameter
/// @param[in] name    The unadorned parameter name specific to the entity
/// @param[out] dfdp   The derivative of the F vector with respect to the parameter
/// @param[out] dqdp   The derivative of the Q vector with respect to the parameter
/// @param[out] dbdp   The derivative of the B vector with respect to the parameter
/// @param[out] Findices   The indices into the F vector corresponding to the elements of dfdp
/// @param[out] Qindices   The indices into the Q vector corresponding to the elements of dfdp
/// @param[out] Bindices   The indices into the B vector corresponding to the elements of dfdp
///
///
void InstanceSensitivity::operator()
(
const ParameterBase &entity,
const std::string &name,
std::vector<double> & dfdp,
std::vector<double> & dqdp,
std::vector<double> & dbdp,
std::vector<int> & Findices,
std::vector<int> & Qindices,
std::vector<int> & Bindices
) const
{
const ParameterBase * e1 = &entity;
const Instance & in = *(dynamic_cast<const Instance *> (e1));
const Model & mod =in.model_;

dfdp.resize(4+0);
dqdp.resize(4+0);
Findices.resize(4+0);
Qindices.resize(4+0);

std::vector <double> probeVars(3);
std::vector <double> d_staticContributions_dX(4+0);
std::vector <double> d_dynamicContributions_dX(4+0);


// initialize contributions to zero (automatically sets derivatives to zero)
for (int i=0; i < 4+0 ; ++i)
{
   d_staticContributions_dX[i]=0;
   d_dynamicContributions_dX[i]=0;
}

// Copy out all the model parameters (doubles) into local structure
modelSensStruct modelStruct;

//reals
modelStruct.modelPar_Trise=mod.Trise;
modelStruct.d_modelPar_Trise_dX=0.0;
modelStruct.modelPar_given_Trise=mod.given("Trise");
modelStruct.modelPar_TEMP=mod.TEMP;
modelStruct.d_modelPar_TEMP_dX=0.0;
modelStruct.modelPar_given_TEMP=mod.given("TEMP");
modelStruct.modelPar_TNOM=mod.TNOM;
modelStruct.d_modelPar_TNOM_dX=0.0;
modelStruct.modelPar_given_TNOM=mod.given("TNOM");
modelStruct.modelPar_L=mod.L;
modelStruct.d_modelPar_L_dX=0.0;
modelStruct.modelPar_given_L=mod.given("L");
modelStruct.modelPar_W=mod.W;
modelStruct.d_modelPar_W_dX=0.0;
modelStruct.modelPar_given_W=mod.given("W");
modelStruct.modelPar_M=mod.M;
modelStruct.d_modelPar_M_dX=0.0;
modelStruct.modelPar_given_M=mod.given("M");
modelStruct.modelPar_NS=mod.NS;
modelStruct.d_modelPar_NS_dX=0.0;
modelStruct.modelPar_given_NS=mod.given("NS");
modelStruct.modelPar_AS=mod.AS;
modelStruct.d_modelPar_AS_dX=0.0;
modelStruct.modelPar_given_AS=mod.given("AS");
modelStruct.modelPar_AD=mod.AD;
modelStruct.d_modelPar_AD_dX=0.0;
modelStruct.modelPar_given_AD=mod.given("AD");
modelStruct.modelPar_PS=mod.PS;
modelStruct.d_modelPar_PS_dX=0.0;
modelStruct.modelPar_given_PS=mod.given("PS");
modelStruct.modelPar_PD=mod.PD;
modelStruct.d_modelPar_PD_dX=0.0;
modelStruct.modelPar_given_PD=mod.given("PD");
modelStruct.modelPar_COX=mod.COX;
modelStruct.d_modelPar_COX_dX=0.0;
modelStruct.modelPar_given_COX=mod.given("COX");
modelStruct.modelPar_XJ=mod.XJ;
modelStruct.d_modelPar_XJ_dX=0.0;
modelStruct.modelPar_given_XJ=mod.given("XJ");
modelStruct.modelPar_VTO=mod.VTO;
modelStruct.d_modelPar_VTO_dX=0.0;
modelStruct.modelPar_given_VTO=mod.given("VTO");
modelStruct.modelPar_TCV=mod.TCV;
modelStruct.d_modelPar_TCV_dX=0.0;
modelStruct.modelPar_given_TCV=mod.given("TCV");
modelStruct.modelPar_GAMMA=mod.GAMMA;
modelStruct.d_modelPar_GAMMA_dX=0.0;
modelStruct.modelPar_given_GAMMA=mod.given("GAMMA");
modelStruct.modelPar_PHI=mod.PHI;
modelStruct.d_modelPar_PHI_dX=0.0;
modelStruct.modelPar_given_PHI=mod.given("PHI");
modelStruct.modelPar_KP=mod.KP;
modelStruct.d_modelPar_KP_dX=0.0;
modelStruct.modelPar_given_KP=mod.given("KP");
modelStruct.modelPar_BEX=mod.BEX;
modelStruct.d_modelPar_BEX_dX=0.0;
modelStruct.modelPar_given_BEX=mod.given("BEX");
modelStruct.modelPar_THETA=mod.THETA;
modelStruct.d_modelPar_THETA_dX=0.0;
modelStruct.modelPar_given_THETA=mod.given("THETA");
modelStruct.modelPar_E0=mod.E0;
modelStruct.d_modelPar_E0_dX=0.0;
modelStruct.modelPar_given_E0=mod.given("E0");
modelStruct.modelPar_UCRIT=mod.UCRIT;
modelStruct.d_modelPar_UCRIT_dX=0.0;
modelStruct.modelPar_given_UCRIT=mod.given("UCRIT");
modelStruct.modelPar_UCEX=mod.UCEX;
modelStruct.d_modelPar_UCEX_dX=0.0;
modelStruct.modelPar_given_UCEX=mod.given("UCEX");
modelStruct.modelPar_LAMBDA=mod.LAMBDA;
modelStruct.d_modelPar_LAMBDA_dX=0.0;
modelStruct.modelPar_given_LAMBDA=mod.given("LAMBDA");
modelStruct.modelPar_DL=mod.DL;
modelStruct.d_modelPar_DL_dX=0.0;
modelStruct.modelPar_given_DL=mod.given("DL");
modelStruct.modelPar_DW=mod.DW;
modelStruct.d_modelPar_DW_dX=0.0;
modelStruct.modelPar_given_DW=mod.given("DW");
modelStruct.modelPar_WETA=mod.WETA;
modelStruct.d_modelPar_WETA_dX=0.0;
modelStruct.modelPar_given_WETA=mod.given("WETA");
modelStruct.modelPar_LETA=mod.LETA;
modelStruct.d_modelPar_LETA_dX=0.0;
modelStruct.modelPar_given_LETA=mod.given("LETA");
modelStruct.modelPar_Q0=mod.Q0;
modelStruct.d_modelPar_Q0_dX=0.0;
modelStruct.modelPar_given_Q0=mod.given("Q0");
modelStruct.modelPar_LK=mod.LK;
modelStruct.d_modelPar_LK_dX=0.0;
modelStruct.modelPar_given_LK=mod.given("LK");
modelStruct.modelPar_IBA=mod.IBA;
modelStruct.d_modelPar_IBA_dX=0.0;
modelStruct.modelPar_given_IBA=mod.given("IBA");
modelStruct.modelPar_IBB=mod.IBB;
modelStruct.d_modelPar_IBB_dX=0.0;
modelStruct.modelPar_given_IBB=mod.given("IBB");
modelStruct.modelPar_IBBT=mod.IBBT;
modelStruct.d_modelPar_IBBT_dX=0.0;
modelStruct.modelPar_given_IBBT=mod.given("IBBT");
modelStruct.modelPar_IBN=mod.IBN;
modelStruct.d_modelPar_IBN_dX=0.0;
modelStruct.modelPar_given_IBN=mod.given("IBN");
modelStruct.modelPar_RSH=mod.RSH;
modelStruct.d_modelPar_RSH_dX=0.0;
modelStruct.modelPar_given_RSH=mod.given("RSH");
modelStruct.modelPar_HDIF=mod.HDIF;
modelStruct.d_modelPar_HDIF_dX=0.0;
modelStruct.modelPar_given_HDIF=mod.given("HDIF");
modelStruct.modelPar_AVTO=mod.AVTO;
modelStruct.d_modelPar_AVTO_dX=0.0;
modelStruct.modelPar_given_AVTO=mod.given("AVTO");
modelStruct.modelPar_AKP=mod.AKP;
modelStruct.d_modelPar_AKP_dX=0.0;
modelStruct.modelPar_given_AKP=mod.given("AKP");
modelStruct.modelPar_AGAMMA=mod.AGAMMA;
modelStruct.d_modelPar_AGAMMA_dX=0.0;
modelStruct.modelPar_given_AGAMMA=mod.given("AGAMMA");
modelStruct.modelPar_AF=mod.AF;
modelStruct.d_modelPar_AF_dX=0.0;
modelStruct.modelPar_given_AF=mod.given("AF");
modelStruct.modelPar_KF=mod.KF;
modelStruct.d_modelPar_KF_dX=0.0;
modelStruct.modelPar_given_KF=mod.given("KF");
modelStruct.modelPar_xd_n=mod.xd_n;
modelStruct.d_modelPar_xd_n_dX=0.0;
modelStruct.modelPar_given_xd_n=mod.given("xd_n");
modelStruct.modelPar_xd_js=mod.xd_js;
modelStruct.d_modelPar_xd_js_dX=0.0;
modelStruct.modelPar_given_xd_js=mod.given("xd_js");
modelStruct.modelPar_xd_jsw=mod.xd_jsw;
modelStruct.d_modelPar_xd_jsw_dX=0.0;
modelStruct.modelPar_given_xd_jsw=mod.given("xd_jsw");
modelStruct.modelPar_xd_jswg=mod.xd_jswg;
modelStruct.d_modelPar_xd_jswg_dX=0.0;
modelStruct.modelPar_given_xd_jswg=mod.given("xd_jswg");
modelStruct.modelPar_xd_mj=mod.xd_mj;
modelStruct.d_modelPar_xd_mj_dX=0.0;
modelStruct.modelPar_given_xd_mj=mod.given("xd_mj");
modelStruct.modelPar_xd_mjsw=mod.xd_mjsw;
modelStruct.d_modelPar_xd_mjsw_dX=0.0;
modelStruct.modelPar_given_xd_mjsw=mod.given("xd_mjsw");
modelStruct.modelPar_xd_mjswg=mod.xd_mjswg;
modelStruct.d_modelPar_xd_mjswg_dX=0.0;
modelStruct.modelPar_given_xd_mjswg=mod.given("xd_mjswg");
modelStruct.modelPar_xd_pb=mod.xd_pb;
modelStruct.d_modelPar_xd_pb_dX=0.0;
modelStruct.modelPar_given_xd_pb=mod.given("xd_pb");
modelStruct.modelPar_xd_pbsw=mod.xd_pbsw;
modelStruct.d_modelPar_xd_pbsw_dX=0.0;
modelStruct.modelPar_given_xd_pbsw=mod.given("xd_pbsw");
modelStruct.modelPar_xd_pbswg=mod.xd_pbswg;
modelStruct.d_modelPar_xd_pbswg_dX=0.0;
modelStruct.modelPar_given_xd_pbswg=mod.given("xd_pbswg");
modelStruct.modelPar_xd_cj=mod.xd_cj;
modelStruct.d_modelPar_xd_cj_dX=0.0;
modelStruct.modelPar_given_xd_cj=mod.given("xd_cj");
modelStruct.modelPar_xd_cjsw=mod.xd_cjsw;
modelStruct.d_modelPar_xd_cjsw_dX=0.0;
modelStruct.modelPar_given_xd_cjsw=mod.given("xd_cjsw");
modelStruct.modelPar_xd_cjswg=mod.xd_cjswg;
modelStruct.d_modelPar_xd_cjswg_dX=0.0;
modelStruct.modelPar_given_xd_cjswg=mod.given("xd_cjswg");
modelStruct.modelPar_xd_gmin=mod.xd_gmin;
modelStruct.d_modelPar_xd_gmin_dX=0.0;
modelStruct.modelPar_given_xd_gmin=mod.given("xd_gmin");
modelStruct.modelPar_xd_xjbv=mod.xd_xjbv;
modelStruct.d_modelPar_xd_xjbv_dX=0.0;
modelStruct.modelPar_given_xd_xjbv=mod.given("xd_xjbv");
modelStruct.modelPar_xd_bv=mod.xd_bv;
modelStruct.d_modelPar_xd_bv_dX=0.0;
modelStruct.modelPar_given_xd_bv=mod.given("xd_bv");
modelStruct.modelPar_xd_njts=mod.xd_njts;
modelStruct.d_modelPar_xd_njts_dX=0.0;
modelStruct.modelPar_given_xd_njts=mod.given("xd_njts");
modelStruct.modelPar_xd_njtssw=mod.xd_njtssw;
modelStruct.d_modelPar_xd_njtssw_dX=0.0;
modelStruct.modelPar_given_xd_njtssw=mod.given("xd_njtssw");
modelStruct.modelPar_xd_njtsswg=mod.xd_njtsswg;
modelStruct.d_modelPar_xd_njtsswg_dX=0.0;
modelStruct.modelPar_given_xd_njtsswg=mod.given("xd_njtsswg");
modelStruct.modelPar_xd_vts=mod.xd_vts;
modelStruct.d_modelPar_xd_vts_dX=0.0;
modelStruct.modelPar_given_xd_vts=mod.given("xd_vts");
modelStruct.modelPar_xd_vtssw=mod.xd_vtssw;
modelStruct.d_modelPar_xd_vtssw_dX=0.0;
modelStruct.modelPar_given_xd_vtssw=mod.given("xd_vtssw");
modelStruct.modelPar_xd_vtsswg=mod.xd_vtsswg;
modelStruct.d_modelPar_xd_vtsswg_dX=0.0;
modelStruct.modelPar_given_xd_vtsswg=mod.given("xd_vtsswg");
modelStruct.modelPar_tp_xti=mod.tp_xti;
modelStruct.d_modelPar_tp_xti_dX=0.0;
modelStruct.modelPar_given_tp_xti=mod.given("tp_xti");
modelStruct.modelPar_tp_cj=mod.tp_cj;
modelStruct.d_modelPar_tp_cj_dX=0.0;
modelStruct.modelPar_given_tp_cj=mod.given("tp_cj");
modelStruct.modelPar_tp_cjsw=mod.tp_cjsw;
modelStruct.d_modelPar_tp_cjsw_dX=0.0;
modelStruct.modelPar_given_tp_cjsw=mod.given("tp_cjsw");
modelStruct.modelPar_tp_cjswg=mod.tp_cjswg;
modelStruct.d_modelPar_tp_cjswg_dX=0.0;
modelStruct.modelPar_given_tp_cjswg=mod.given("tp_cjswg");
modelStruct.modelPar_tp_pb=mod.tp_pb;
modelStruct.d_modelPar_tp_pb_dX=0.0;
modelStruct.modelPar_given_tp_pb=mod.given("tp_pb");
modelStruct.modelPar_tp_pbsw=mod.tp_pbsw;
modelStruct.d_modelPar_tp_pbsw_dX=0.0;
modelStruct.modelPar_given_tp_pbsw=mod.given("tp_pbsw");
modelStruct.modelPar_tp_pbswg=mod.tp_pbswg;
modelStruct.d_modelPar_tp_pbswg_dX=0.0;
modelStruct.modelPar_given_tp_pbswg=mod.given("tp_pbswg");
modelStruct.modelPar_tp_njts=mod.tp_njts;
modelStruct.d_modelPar_tp_njts_dX=0.0;
modelStruct.modelPar_given_tp_njts=mod.given("tp_njts");
modelStruct.modelPar_tp_njtssw=mod.tp_njtssw;
modelStruct.d_modelPar_tp_njtssw_dX=0.0;
modelStruct.modelPar_given_tp_njtssw=mod.given("tp_njtssw");
modelStruct.modelPar_tp_njtsswg=mod.tp_njtsswg;
modelStruct.d_modelPar_tp_njtsswg_dX=0.0;
modelStruct.modelPar_given_tp_njtsswg=mod.given("tp_njtsswg");
modelStruct.modelPar_LMIN=mod.LMIN;
modelStruct.d_modelPar_LMIN_dX=0.0;
modelStruct.modelPar_given_LMIN=mod.given("LMIN");
modelStruct.modelPar_LMAX=mod.LMAX;
modelStruct.d_modelPar_LMAX_dX=0.0;
modelStruct.modelPar_given_LMAX=mod.given("LMAX");
modelStruct.modelPar_WMIN=mod.WMIN;
modelStruct.d_modelPar_WMIN_dX=0.0;
modelStruct.modelPar_given_WMIN=mod.given("WMIN");
modelStruct.modelPar_WMAX=mod.WMAX;
modelStruct.d_modelPar_WMAX_dX=0.0;
modelStruct.modelPar_given_WMAX=mod.given("WMAX");


// hidden reals


// non-reals (including hiddens)
modelStruct.modelPar_TYPE=mod.TYPE;
modelStruct.modelPar_given_TYPE=mod.given("TYPE");
modelStruct.modelPar_Noise=mod.Noise;
modelStruct.modelPar_given_Noise=mod.given("Noise");



// Copy out all the instance parameters (doubles) into local struct
// Keep a map so we can set the right one to the independent variable
// We do this solely to avoid a big ugly "if/else" block just to find the
// one parameter we're doing sensitivities on.
unordered_map <std::string,double*,HashNoCase,EqualNoCase> inParamMap;
instanceSensStruct instanceStruct;
// reals
instanceStruct.instancePar_L=in.L;
instanceStruct.d_instancePar_L_dX=0.0;
instanceStruct.instancePar_given_L=in.given("L");
inParamMap["L"] = &(instanceStruct.d_instancePar_L_dX);
instanceStruct.instancePar_W=in.W;
instanceStruct.d_instancePar_W_dX=0.0;
instanceStruct.instancePar_given_W=in.given("W");
inParamMap["W"] = &(instanceStruct.d_instancePar_W_dX);
instanceStruct.instancePar_M=in.M;
instanceStruct.d_instancePar_M_dX=0.0;
instanceStruct.instancePar_given_M=in.given("M");
inParamMap["M"] = &(instanceStruct.d_instancePar_M_dX);
instanceStruct.instancePar_NS=in.NS;
instanceStruct.d_instancePar_NS_dX=0.0;
instanceStruct.instancePar_given_NS=in.given("NS");
inParamMap["NS"] = &(instanceStruct.d_instancePar_NS_dX);
instanceStruct.instancePar_AS=in.AS;
instanceStruct.d_instancePar_AS_dX=0.0;
instanceStruct.instancePar_given_AS=in.given("AS");
inParamMap["AS"] = &(instanceStruct.d_instancePar_AS_dX);
instanceStruct.instancePar_AD=in.AD;
instanceStruct.d_instancePar_AD_dX=0.0;
instanceStruct.instancePar_given_AD=in.given("AD");
inParamMap["AD"] = &(instanceStruct.d_instancePar_AD_dX);
instanceStruct.instancePar_PS=in.PS;
instanceStruct.d_instancePar_PS_dX=0.0;
instanceStruct.instancePar_given_PS=in.given("PS");
inParamMap["PS"] = &(instanceStruct.d_instancePar_PS_dX);
instanceStruct.instancePar_PD=in.PD;
instanceStruct.d_instancePar_PD_dX=0.0;
instanceStruct.instancePar_given_PD=in.given("PD");
inParamMap["PD"] = &(instanceStruct.d_instancePar_PD_dX);


// Copy all the real hidden instance params into local struct



// Copy all the non-real instance params into vars of their appropriate type:


// Set the one parameter whose name was passed in to be the independent
// variable for differentiation purposes.  Since we stored variable pointers, this
// makes sure that that ONE variable gets set right.
// FIXME: make this check the name first, otherwise segfault on invalid name!
*(inParamMap[name])=1.0;

//make local copies of all instance vars
//reals


//non-reals


//make local copies of all model vars
//reals


// non-reals



Linear::Vector * solVectorPtr = in.extData.nextSolVectorPtr;

// extract solution variables
probeVars[in.admsProbeID_V_d_b] = (*solVectorPtr)[in.li_d]- (*solVectorPtr)[in.li_b];
probeVars[in.admsProbeID_V_s_b] = (*solVectorPtr)[in.li_s]- (*solVectorPtr)[in.li_b];
probeVars[in.admsProbeID_V_g_b] = (*solVectorPtr)[in.li_g]- (*solVectorPtr)[in.li_b];




// Now call  the function that does the heavy lifting.
evaluateModelEquations(
probeVars,
// probe constants
in.admsProbeID_V_d_b,
in.admsProbeID_V_s_b,
in.admsProbeID_V_g_b,

// node constants
in.admsNodeID_d,
in.admsNodeID_g,
in.admsNodeID_s,
in.admsNodeID_b,
instanceStruct,
modelStruct,
 in.admsTemperature,
 in.adms_vt_nom,
 in.getDeviceOptions().gmin,
 d_staticContributions_dX,
 d_dynamicContributions_dX,
 in);


// We now have the F and Q vector stuff, populate the dependencies:

    dfdp[in.admsNodeID_d] += d_staticContributions_dX[in.admsNodeID_d];
    dqdp[in.admsNodeID_d] += d_dynamicContributions_dX[in.admsNodeID_d];
    Findices[in.admsNodeID_d] = in.li_d;
    Qindices[in.admsNodeID_d] = in.li_d;
    dfdp[in.admsNodeID_g] += d_staticContributions_dX[in.admsNodeID_g];
    dqdp[in.admsNodeID_g] += d_dynamicContributions_dX[in.admsNodeID_g];
    Findices[in.admsNodeID_g] = in.li_g;
    Qindices[in.admsNodeID_g] = in.li_g;
    dfdp[in.admsNodeID_s] += d_staticContributions_dX[in.admsNodeID_s];
    dqdp[in.admsNodeID_s] += d_dynamicContributions_dX[in.admsNodeID_s];
    Findices[in.admsNodeID_s] = in.li_s;
    Qindices[in.admsNodeID_s] = in.li_s;
    dfdp[in.admsNodeID_b] += d_staticContributions_dX[in.admsNodeID_b];
    dqdp[in.admsNodeID_b] += d_dynamicContributions_dX[in.admsNodeID_b];
    Findices[in.admsNodeID_b] = in.li_b;
    Qindices[in.admsNodeID_b] = in.li_b;


}

//-----------------------------------------------------------------------------
// Function      : ModelSensitivity::operator()
// Purpose       : return sensitivity for a single model parameter
// Special Notes :
// Scope         : public
// Creator       : admsXml
// Creation Date :
//-----------------------------------------------------------------------------
/// Compute sensitivity to a specified model
/// parameter of all device instances of that model's outputs
///
///
/// @param[in] entity  The device entity that owns the parameter
/// @param[in] name    The unadorned parameter name specific to the entity
/// @param[out] dfdp   The derivative of the F vector with respect to the parameter
/// @param[out] dqdp   The derivative of the Q vector with respect to the parameter
/// @param[out] dbdp   The derivative of the B vector with respect to the parameter
/// @param[out] Findices   The indices into the F vector corresponding to the elements of dfdp
/// @param[out] Qindices   The indices into the Q vector corresponding to the elements of dfdp
/// @param[out] Bindices   The indices into the B vector corresponding to the elements of dfdp
///
///
void ModelSensitivity::operator()
(
const ParameterBase &entity,
const std::string &name,
std::vector<double> & dfdp,
std::vector<double> & dqdp,
std::vector<double> & dbdp,
std::vector<int> & Findices,
std::vector<int> & Qindices,
std::vector<int> & Bindices
) const
{
const ParameterBase * e1 = &entity;
const Model & mod = *(dynamic_cast<const Model *> (e1));
int sizeInstance = mod.instanceContainer.size();

dfdp.resize((4+0)*sizeInstance);
dqdp.resize((4+0)*sizeInstance);
Findices.resize((4+0)*sizeInstance);
Qindices.resize((4+0)*sizeInstance);

std::vector <double> probeVars(3);
std::vector <double> d_staticContributions_dX(4+0);
std::vector <double> d_dynamicContributions_dX(4+0);


// Copy out all the model parameters (doubles) into local structure
modelSensStruct modelStruct;

// Keep a map so we can set the right one to the independent variable
// We do this solely to avoid a big ugly "if/else" block just to find the
// one parameter we're doing sensitivities on.
unordered_map <std::string,double*,HashNoCase,EqualNoCase> modParamMap;

// reals
modelStruct.modelPar_Trise=mod.Trise;
modelStruct.d_modelPar_Trise_dX=0.0;
modelStruct.modelPar_given_Trise=mod.given("Trise");
modParamMap["Trise"] = &(modelStruct.d_modelPar_Trise_dX);
modelStruct.modelPar_TEMP=mod.TEMP;
modelStruct.d_modelPar_TEMP_dX=0.0;
modelStruct.modelPar_given_TEMP=mod.given("TEMP");
modParamMap["TEMP"] = &(modelStruct.d_modelPar_TEMP_dX);
modelStruct.modelPar_TNOM=mod.TNOM;
modelStruct.d_modelPar_TNOM_dX=0.0;
modelStruct.modelPar_given_TNOM=mod.given("TNOM");
modParamMap["TNOM"] = &(modelStruct.d_modelPar_TNOM_dX);
modelStruct.modelPar_L=mod.L;
modelStruct.d_modelPar_L_dX=0.0;
modelStruct.modelPar_given_L=mod.given("L");
modParamMap["L"] = &(modelStruct.d_modelPar_L_dX);
modelStruct.modelPar_W=mod.W;
modelStruct.d_modelPar_W_dX=0.0;
modelStruct.modelPar_given_W=mod.given("W");
modParamMap["W"] = &(modelStruct.d_modelPar_W_dX);
modelStruct.modelPar_M=mod.M;
modelStruct.d_modelPar_M_dX=0.0;
modelStruct.modelPar_given_M=mod.given("M");
modParamMap["M"] = &(modelStruct.d_modelPar_M_dX);
modelStruct.modelPar_NS=mod.NS;
modelStruct.d_modelPar_NS_dX=0.0;
modelStruct.modelPar_given_NS=mod.given("NS");
modParamMap["NS"] = &(modelStruct.d_modelPar_NS_dX);
modelStruct.modelPar_AS=mod.AS;
modelStruct.d_modelPar_AS_dX=0.0;
modelStruct.modelPar_given_AS=mod.given("AS");
modParamMap["AS"] = &(modelStruct.d_modelPar_AS_dX);
modelStruct.modelPar_AD=mod.AD;
modelStruct.d_modelPar_AD_dX=0.0;
modelStruct.modelPar_given_AD=mod.given("AD");
modParamMap["AD"] = &(modelStruct.d_modelPar_AD_dX);
modelStruct.modelPar_PS=mod.PS;
modelStruct.d_modelPar_PS_dX=0.0;
modelStruct.modelPar_given_PS=mod.given("PS");
modParamMap["PS"] = &(modelStruct.d_modelPar_PS_dX);
modelStruct.modelPar_PD=mod.PD;
modelStruct.d_modelPar_PD_dX=0.0;
modelStruct.modelPar_given_PD=mod.given("PD");
modParamMap["PD"] = &(modelStruct.d_modelPar_PD_dX);
modelStruct.modelPar_COX=mod.COX;
modelStruct.d_modelPar_COX_dX=0.0;
modelStruct.modelPar_given_COX=mod.given("COX");
modParamMap["COX"] = &(modelStruct.d_modelPar_COX_dX);
modelStruct.modelPar_XJ=mod.XJ;
modelStruct.d_modelPar_XJ_dX=0.0;
modelStruct.modelPar_given_XJ=mod.given("XJ");
modParamMap["XJ"] = &(modelStruct.d_modelPar_XJ_dX);
modelStruct.modelPar_VTO=mod.VTO;
modelStruct.d_modelPar_VTO_dX=0.0;
modelStruct.modelPar_given_VTO=mod.given("VTO");
modParamMap["VTO"] = &(modelStruct.d_modelPar_VTO_dX);
modelStruct.modelPar_TCV=mod.TCV;
modelStruct.d_modelPar_TCV_dX=0.0;
modelStruct.modelPar_given_TCV=mod.given("TCV");
modParamMap["TCV"] = &(modelStruct.d_modelPar_TCV_dX);
modelStruct.modelPar_GAMMA=mod.GAMMA;
modelStruct.d_modelPar_GAMMA_dX=0.0;
modelStruct.modelPar_given_GAMMA=mod.given("GAMMA");
modParamMap["GAMMA"] = &(modelStruct.d_modelPar_GAMMA_dX);
modelStruct.modelPar_PHI=mod.PHI;
modelStruct.d_modelPar_PHI_dX=0.0;
modelStruct.modelPar_given_PHI=mod.given("PHI");
modParamMap["PHI"] = &(modelStruct.d_modelPar_PHI_dX);
modelStruct.modelPar_KP=mod.KP;
modelStruct.d_modelPar_KP_dX=0.0;
modelStruct.modelPar_given_KP=mod.given("KP");
modParamMap["KP"] = &(modelStruct.d_modelPar_KP_dX);
modelStruct.modelPar_BEX=mod.BEX;
modelStruct.d_modelPar_BEX_dX=0.0;
modelStruct.modelPar_given_BEX=mod.given("BEX");
modParamMap["BEX"] = &(modelStruct.d_modelPar_BEX_dX);
modelStruct.modelPar_THETA=mod.THETA;
modelStruct.d_modelPar_THETA_dX=0.0;
modelStruct.modelPar_given_THETA=mod.given("THETA");
modParamMap["THETA"] = &(modelStruct.d_modelPar_THETA_dX);
modelStruct.modelPar_E0=mod.E0;
modelStruct.d_modelPar_E0_dX=0.0;
modelStruct.modelPar_given_E0=mod.given("E0");
modParamMap["E0"] = &(modelStruct.d_modelPar_E0_dX);
modelStruct.modelPar_UCRIT=mod.UCRIT;
modelStruct.d_modelPar_UCRIT_dX=0.0;
modelStruct.modelPar_given_UCRIT=mod.given("UCRIT");
modParamMap["UCRIT"] = &(modelStruct.d_modelPar_UCRIT_dX);
modelStruct.modelPar_UCEX=mod.UCEX;
modelStruct.d_modelPar_UCEX_dX=0.0;
modelStruct.modelPar_given_UCEX=mod.given("UCEX");
modParamMap["UCEX"] = &(modelStruct.d_modelPar_UCEX_dX);
modelStruct.modelPar_LAMBDA=mod.LAMBDA;
modelStruct.d_modelPar_LAMBDA_dX=0.0;
modelStruct.modelPar_given_LAMBDA=mod.given("LAMBDA");
modParamMap["LAMBDA"] = &(modelStruct.d_modelPar_LAMBDA_dX);
modelStruct.modelPar_DL=mod.DL;
modelStruct.d_modelPar_DL_dX=0.0;
modelStruct.modelPar_given_DL=mod.given("DL");
modParamMap["DL"] = &(modelStruct.d_modelPar_DL_dX);
modelStruct.modelPar_DW=mod.DW;
modelStruct.d_modelPar_DW_dX=0.0;
modelStruct.modelPar_given_DW=mod.given("DW");
modParamMap["DW"] = &(modelStruct.d_modelPar_DW_dX);
modelStruct.modelPar_WETA=mod.WETA;
modelStruct.d_modelPar_WETA_dX=0.0;
modelStruct.modelPar_given_WETA=mod.given("WETA");
modParamMap["WETA"] = &(modelStruct.d_modelPar_WETA_dX);
modelStruct.modelPar_LETA=mod.LETA;
modelStruct.d_modelPar_LETA_dX=0.0;
modelStruct.modelPar_given_LETA=mod.given("LETA");
modParamMap["LETA"] = &(modelStruct.d_modelPar_LETA_dX);
modelStruct.modelPar_Q0=mod.Q0;
modelStruct.d_modelPar_Q0_dX=0.0;
modelStruct.modelPar_given_Q0=mod.given("Q0");
modParamMap["Q0"] = &(modelStruct.d_modelPar_Q0_dX);
modelStruct.modelPar_LK=mod.LK;
modelStruct.d_modelPar_LK_dX=0.0;
modelStruct.modelPar_given_LK=mod.given("LK");
modParamMap["LK"] = &(modelStruct.d_modelPar_LK_dX);
modelStruct.modelPar_IBA=mod.IBA;
modelStruct.d_modelPar_IBA_dX=0.0;
modelStruct.modelPar_given_IBA=mod.given("IBA");
modParamMap["IBA"] = &(modelStruct.d_modelPar_IBA_dX);
modelStruct.modelPar_IBB=mod.IBB;
modelStruct.d_modelPar_IBB_dX=0.0;
modelStruct.modelPar_given_IBB=mod.given("IBB");
modParamMap["IBB"] = &(modelStruct.d_modelPar_IBB_dX);
modelStruct.modelPar_IBBT=mod.IBBT;
modelStruct.d_modelPar_IBBT_dX=0.0;
modelStruct.modelPar_given_IBBT=mod.given("IBBT");
modParamMap["IBBT"] = &(modelStruct.d_modelPar_IBBT_dX);
modelStruct.modelPar_IBN=mod.IBN;
modelStruct.d_modelPar_IBN_dX=0.0;
modelStruct.modelPar_given_IBN=mod.given("IBN");
modParamMap["IBN"] = &(modelStruct.d_modelPar_IBN_dX);
modelStruct.modelPar_RSH=mod.RSH;
modelStruct.d_modelPar_RSH_dX=0.0;
modelStruct.modelPar_given_RSH=mod.given("RSH");
modParamMap["RSH"] = &(modelStruct.d_modelPar_RSH_dX);
modelStruct.modelPar_HDIF=mod.HDIF;
modelStruct.d_modelPar_HDIF_dX=0.0;
modelStruct.modelPar_given_HDIF=mod.given("HDIF");
modParamMap["HDIF"] = &(modelStruct.d_modelPar_HDIF_dX);
modelStruct.modelPar_AVTO=mod.AVTO;
modelStruct.d_modelPar_AVTO_dX=0.0;
modelStruct.modelPar_given_AVTO=mod.given("AVTO");
modParamMap["AVTO"] = &(modelStruct.d_modelPar_AVTO_dX);
modelStruct.modelPar_AKP=mod.AKP;
modelStruct.d_modelPar_AKP_dX=0.0;
modelStruct.modelPar_given_AKP=mod.given("AKP");
modParamMap["AKP"] = &(modelStruct.d_modelPar_AKP_dX);
modelStruct.modelPar_AGAMMA=mod.AGAMMA;
modelStruct.d_modelPar_AGAMMA_dX=0.0;
modelStruct.modelPar_given_AGAMMA=mod.given("AGAMMA");
modParamMap["AGAMMA"] = &(modelStruct.d_modelPar_AGAMMA_dX);
modelStruct.modelPar_AF=mod.AF;
modelStruct.d_modelPar_AF_dX=0.0;
modelStruct.modelPar_given_AF=mod.given("AF");
modParamMap["AF"] = &(modelStruct.d_modelPar_AF_dX);
modelStruct.modelPar_KF=mod.KF;
modelStruct.d_modelPar_KF_dX=0.0;
modelStruct.modelPar_given_KF=mod.given("KF");
modParamMap["KF"] = &(modelStruct.d_modelPar_KF_dX);
modelStruct.modelPar_xd_n=mod.xd_n;
modelStruct.d_modelPar_xd_n_dX=0.0;
modelStruct.modelPar_given_xd_n=mod.given("xd_n");
modParamMap["xd_n"] = &(modelStruct.d_modelPar_xd_n_dX);
modelStruct.modelPar_xd_js=mod.xd_js;
modelStruct.d_modelPar_xd_js_dX=0.0;
modelStruct.modelPar_given_xd_js=mod.given("xd_js");
modParamMap["xd_js"] = &(modelStruct.d_modelPar_xd_js_dX);
modelStruct.modelPar_xd_jsw=mod.xd_jsw;
modelStruct.d_modelPar_xd_jsw_dX=0.0;
modelStruct.modelPar_given_xd_jsw=mod.given("xd_jsw");
modParamMap["xd_jsw"] = &(modelStruct.d_modelPar_xd_jsw_dX);
modelStruct.modelPar_xd_jswg=mod.xd_jswg;
modelStruct.d_modelPar_xd_jswg_dX=0.0;
modelStruct.modelPar_given_xd_jswg=mod.given("xd_jswg");
modParamMap["xd_jswg"] = &(modelStruct.d_modelPar_xd_jswg_dX);
modelStruct.modelPar_xd_mj=mod.xd_mj;
modelStruct.d_modelPar_xd_mj_dX=0.0;
modelStruct.modelPar_given_xd_mj=mod.given("xd_mj");
modParamMap["xd_mj"] = &(modelStruct.d_modelPar_xd_mj_dX);
modelStruct.modelPar_xd_mjsw=mod.xd_mjsw;
modelStruct.d_modelPar_xd_mjsw_dX=0.0;
modelStruct.modelPar_given_xd_mjsw=mod.given("xd_mjsw");
modParamMap["xd_mjsw"] = &(modelStruct.d_modelPar_xd_mjsw_dX);
modelStruct.modelPar_xd_mjswg=mod.xd_mjswg;
modelStruct.d_modelPar_xd_mjswg_dX=0.0;
modelStruct.modelPar_given_xd_mjswg=mod.given("xd_mjswg");
modParamMap["xd_mjswg"] = &(modelStruct.d_modelPar_xd_mjswg_dX);
modelStruct.modelPar_xd_pb=mod.xd_pb;
modelStruct.d_modelPar_xd_pb_dX=0.0;
modelStruct.modelPar_given_xd_pb=mod.given("xd_pb");
modParamMap["xd_pb"] = &(modelStruct.d_modelPar_xd_pb_dX);
modelStruct.modelPar_xd_pbsw=mod.xd_pbsw;
modelStruct.d_modelPar_xd_pbsw_dX=0.0;
modelStruct.modelPar_given_xd_pbsw=mod.given("xd_pbsw");
modParamMap["xd_pbsw"] = &(modelStruct.d_modelPar_xd_pbsw_dX);
modelStruct.modelPar_xd_pbswg=mod.xd_pbswg;
modelStruct.d_modelPar_xd_pbswg_dX=0.0;
modelStruct.modelPar_given_xd_pbswg=mod.given("xd_pbswg");
modParamMap["xd_pbswg"] = &(modelStruct.d_modelPar_xd_pbswg_dX);
modelStruct.modelPar_xd_cj=mod.xd_cj;
modelStruct.d_modelPar_xd_cj_dX=0.0;
modelStruct.modelPar_given_xd_cj=mod.given("xd_cj");
modParamMap["xd_cj"] = &(modelStruct.d_modelPar_xd_cj_dX);
modelStruct.modelPar_xd_cjsw=mod.xd_cjsw;
modelStruct.d_modelPar_xd_cjsw_dX=0.0;
modelStruct.modelPar_given_xd_cjsw=mod.given("xd_cjsw");
modParamMap["xd_cjsw"] = &(modelStruct.d_modelPar_xd_cjsw_dX);
modelStruct.modelPar_xd_cjswg=mod.xd_cjswg;
modelStruct.d_modelPar_xd_cjswg_dX=0.0;
modelStruct.modelPar_given_xd_cjswg=mod.given("xd_cjswg");
modParamMap["xd_cjswg"] = &(modelStruct.d_modelPar_xd_cjswg_dX);
modelStruct.modelPar_xd_gmin=mod.xd_gmin;
modelStruct.d_modelPar_xd_gmin_dX=0.0;
modelStruct.modelPar_given_xd_gmin=mod.given("xd_gmin");
modParamMap["xd_gmin"] = &(modelStruct.d_modelPar_xd_gmin_dX);
modelStruct.modelPar_xd_xjbv=mod.xd_xjbv;
modelStruct.d_modelPar_xd_xjbv_dX=0.0;
modelStruct.modelPar_given_xd_xjbv=mod.given("xd_xjbv");
modParamMap["xd_xjbv"] = &(modelStruct.d_modelPar_xd_xjbv_dX);
modelStruct.modelPar_xd_bv=mod.xd_bv;
modelStruct.d_modelPar_xd_bv_dX=0.0;
modelStruct.modelPar_given_xd_bv=mod.given("xd_bv");
modParamMap["xd_bv"] = &(modelStruct.d_modelPar_xd_bv_dX);
modelStruct.modelPar_xd_njts=mod.xd_njts;
modelStruct.d_modelPar_xd_njts_dX=0.0;
modelStruct.modelPar_given_xd_njts=mod.given("xd_njts");
modParamMap["xd_njts"] = &(modelStruct.d_modelPar_xd_njts_dX);
modelStruct.modelPar_xd_njtssw=mod.xd_njtssw;
modelStruct.d_modelPar_xd_njtssw_dX=0.0;
modelStruct.modelPar_given_xd_njtssw=mod.given("xd_njtssw");
modParamMap["xd_njtssw"] = &(modelStruct.d_modelPar_xd_njtssw_dX);
modelStruct.modelPar_xd_njtsswg=mod.xd_njtsswg;
modelStruct.d_modelPar_xd_njtsswg_dX=0.0;
modelStruct.modelPar_given_xd_njtsswg=mod.given("xd_njtsswg");
modParamMap["xd_njtsswg"] = &(modelStruct.d_modelPar_xd_njtsswg_dX);
modelStruct.modelPar_xd_vts=mod.xd_vts;
modelStruct.d_modelPar_xd_vts_dX=0.0;
modelStruct.modelPar_given_xd_vts=mod.given("xd_vts");
modParamMap["xd_vts"] = &(modelStruct.d_modelPar_xd_vts_dX);
modelStruct.modelPar_xd_vtssw=mod.xd_vtssw;
modelStruct.d_modelPar_xd_vtssw_dX=0.0;
modelStruct.modelPar_given_xd_vtssw=mod.given("xd_vtssw");
modParamMap["xd_vtssw"] = &(modelStruct.d_modelPar_xd_vtssw_dX);
modelStruct.modelPar_xd_vtsswg=mod.xd_vtsswg;
modelStruct.d_modelPar_xd_vtsswg_dX=0.0;
modelStruct.modelPar_given_xd_vtsswg=mod.given("xd_vtsswg");
modParamMap["xd_vtsswg"] = &(modelStruct.d_modelPar_xd_vtsswg_dX);
modelStruct.modelPar_tp_xti=mod.tp_xti;
modelStruct.d_modelPar_tp_xti_dX=0.0;
modelStruct.modelPar_given_tp_xti=mod.given("tp_xti");
modParamMap["tp_xti"] = &(modelStruct.d_modelPar_tp_xti_dX);
modelStruct.modelPar_tp_cj=mod.tp_cj;
modelStruct.d_modelPar_tp_cj_dX=0.0;
modelStruct.modelPar_given_tp_cj=mod.given("tp_cj");
modParamMap["tp_cj"] = &(modelStruct.d_modelPar_tp_cj_dX);
modelStruct.modelPar_tp_cjsw=mod.tp_cjsw;
modelStruct.d_modelPar_tp_cjsw_dX=0.0;
modelStruct.modelPar_given_tp_cjsw=mod.given("tp_cjsw");
modParamMap["tp_cjsw"] = &(modelStruct.d_modelPar_tp_cjsw_dX);
modelStruct.modelPar_tp_cjswg=mod.tp_cjswg;
modelStruct.d_modelPar_tp_cjswg_dX=0.0;
modelStruct.modelPar_given_tp_cjswg=mod.given("tp_cjswg");
modParamMap["tp_cjswg"] = &(modelStruct.d_modelPar_tp_cjswg_dX);
modelStruct.modelPar_tp_pb=mod.tp_pb;
modelStruct.d_modelPar_tp_pb_dX=0.0;
modelStruct.modelPar_given_tp_pb=mod.given("tp_pb");
modParamMap["tp_pb"] = &(modelStruct.d_modelPar_tp_pb_dX);
modelStruct.modelPar_tp_pbsw=mod.tp_pbsw;
modelStruct.d_modelPar_tp_pbsw_dX=0.0;
modelStruct.modelPar_given_tp_pbsw=mod.given("tp_pbsw");
modParamMap["tp_pbsw"] = &(modelStruct.d_modelPar_tp_pbsw_dX);
modelStruct.modelPar_tp_pbswg=mod.tp_pbswg;
modelStruct.d_modelPar_tp_pbswg_dX=0.0;
modelStruct.modelPar_given_tp_pbswg=mod.given("tp_pbswg");
modParamMap["tp_pbswg"] = &(modelStruct.d_modelPar_tp_pbswg_dX);
modelStruct.modelPar_tp_njts=mod.tp_njts;
modelStruct.d_modelPar_tp_njts_dX=0.0;
modelStruct.modelPar_given_tp_njts=mod.given("tp_njts");
modParamMap["tp_njts"] = &(modelStruct.d_modelPar_tp_njts_dX);
modelStruct.modelPar_tp_njtssw=mod.tp_njtssw;
modelStruct.d_modelPar_tp_njtssw_dX=0.0;
modelStruct.modelPar_given_tp_njtssw=mod.given("tp_njtssw");
modParamMap["tp_njtssw"] = &(modelStruct.d_modelPar_tp_njtssw_dX);
modelStruct.modelPar_tp_njtsswg=mod.tp_njtsswg;
modelStruct.d_modelPar_tp_njtsswg_dX=0.0;
modelStruct.modelPar_given_tp_njtsswg=mod.given("tp_njtsswg");
modParamMap["tp_njtsswg"] = &(modelStruct.d_modelPar_tp_njtsswg_dX);
modelStruct.modelPar_LMIN=mod.LMIN;
modelStruct.d_modelPar_LMIN_dX=0.0;
modelStruct.modelPar_given_LMIN=mod.given("LMIN");
modParamMap["LMIN"] = &(modelStruct.d_modelPar_LMIN_dX);
modelStruct.modelPar_LMAX=mod.LMAX;
modelStruct.d_modelPar_LMAX_dX=0.0;
modelStruct.modelPar_given_LMAX=mod.given("LMAX");
modParamMap["LMAX"] = &(modelStruct.d_modelPar_LMAX_dX);
modelStruct.modelPar_WMIN=mod.WMIN;
modelStruct.d_modelPar_WMIN_dX=0.0;
modelStruct.modelPar_given_WMIN=mod.given("WMIN");
modParamMap["WMIN"] = &(modelStruct.d_modelPar_WMIN_dX);
modelStruct.modelPar_WMAX=mod.WMAX;
modelStruct.d_modelPar_WMAX_dX=0.0;
modelStruct.modelPar_given_WMAX=mod.given("WMAX");
modParamMap["WMAX"] = &(modelStruct.d_modelPar_WMAX_dX);


// hidden reals


// non-reals (including hiddens)
modelStruct.modelPar_TYPE=mod.TYPE;
modelStruct.modelPar_given_TYPE=mod.given("TYPE");
modelStruct.modelPar_Noise=mod.Noise;
modelStruct.modelPar_given_Noise=mod.given("Noise");


// Set the one parameter whose name was passed in to be the independent
// variable for differentiation purposes.  Since we stored variable pointers, this
// makes sure that that ONE variable gets set right.
// FIXME: make this check name for presence first!  Segfault on invalid.
*(modParamMap[name])=1.0;

//make local copies of all model vars
//reals


// non-reals



// Now loop over all instances and do the deed
int inst=0;
for (std::vector<Instance*>::const_iterator in_it=mod.instanceContainer.begin(); in_it != mod.instanceContainer.end(); ++in_it,++inst)
{

  Instance & in=*(*in_it);
  // initialize contributions to zero (automatically sets derivatives to zero)
  for (int i=0; i < 4+0 ; ++i)
  {
  d_staticContributions_dX[i]=0;
  d_dynamicContributions_dX[i]=0;
  }



  // Copy out all the instance parameters (doubles) into local struct
 instanceSensStruct instanceStruct;

 // reals
instanceStruct.instancePar_L=in.L;
instanceStruct.d_instancePar_L_dX=0.0;
instanceStruct.instancePar_given_L=in.given("L");
instanceStruct.instancePar_W=in.W;
instanceStruct.d_instancePar_W_dX=0.0;
instanceStruct.instancePar_given_W=in.given("W");
instanceStruct.instancePar_M=in.M;
instanceStruct.d_instancePar_M_dX=0.0;
instanceStruct.instancePar_given_M=in.given("M");
instanceStruct.instancePar_NS=in.NS;
instanceStruct.d_instancePar_NS_dX=0.0;
instanceStruct.instancePar_given_NS=in.given("NS");
instanceStruct.instancePar_AS=in.AS;
instanceStruct.d_instancePar_AS_dX=0.0;
instanceStruct.instancePar_given_AS=in.given("AS");
instanceStruct.instancePar_AD=in.AD;
instanceStruct.d_instancePar_AD_dX=0.0;
instanceStruct.instancePar_given_AD=in.given("AD");
instanceStruct.instancePar_PS=in.PS;
instanceStruct.d_instancePar_PS_dX=0.0;
instanceStruct.instancePar_given_PS=in.given("PS");
instanceStruct.instancePar_PD=in.PD;
instanceStruct.d_instancePar_PD_dX=0.0;
instanceStruct.instancePar_given_PD=in.given("PD");


  // real hidden instance


  // Copy all the non-real instance params into vars of their appropriate type:




  // If there are any instance parameters that were not given, and have
  // corresponding model params, copy the model param into the instance.
  // This was already done by the instance constructor, but we do it again
  // because now we're propagating derivatives, and the user could be trying
  // to get sensitivity to the model parameter.
   if (!(in.given("L")))
   {
      instanceStruct.instancePar_L = modelStruct.modelPar_L;
      instanceStruct.d_instancePar_L_dX = modelStruct.d_modelPar_L_dX;
   }
   if (!(in.given("W")))
   {
      instanceStruct.instancePar_W = modelStruct.modelPar_W;
      instanceStruct.d_instancePar_W_dX = modelStruct.d_modelPar_W_dX;
   }
   if (!(in.given("M")))
   {
      instanceStruct.instancePar_M = modelStruct.modelPar_M;
      instanceStruct.d_instancePar_M_dX = modelStruct.d_modelPar_M_dX;
   }
   if (!(in.given("NS")))
   {
      instanceStruct.instancePar_NS = modelStruct.modelPar_NS;
      instanceStruct.d_instancePar_NS_dX = modelStruct.d_modelPar_NS_dX;
   }
   if (!(in.given("AS")))
   {
      instanceStruct.instancePar_AS = modelStruct.modelPar_AS;
      instanceStruct.d_instancePar_AS_dX = modelStruct.d_modelPar_AS_dX;
   }
   if (!(in.given("AD")))
   {
      instanceStruct.instancePar_AD = modelStruct.modelPar_AD;
      instanceStruct.d_instancePar_AD_dX = modelStruct.d_modelPar_AD_dX;
   }
   if (!(in.given("PS")))
   {
      instanceStruct.instancePar_PS = modelStruct.modelPar_PS;
      instanceStruct.d_instancePar_PS_dX = modelStruct.d_modelPar_PS_dX;
   }
   if (!(in.given("PD")))
   {
      instanceStruct.instancePar_PD = modelStruct.modelPar_PD;
      instanceStruct.d_instancePar_PD_dX = modelStruct.d_modelPar_PD_dX;
   }


  //make local copies of all instance vars
  //reals


  //non-reals



  Linear::Vector * solVectorPtr = in.extData.nextSolVectorPtr;

  // extract solution variables
probeVars[in.admsProbeID_V_d_b] = (*solVectorPtr)[in.li_d] - (*solVectorPtr)[in.li_b];
probeVars[in.admsProbeID_V_s_b] = (*solVectorPtr)[in.li_s] - (*solVectorPtr)[in.li_b];
probeVars[in.admsProbeID_V_g_b] = (*solVectorPtr)[in.li_g] - (*solVectorPtr)[in.li_b];




// Now call  the function that does the heavy lifting.

evaluateModelEquations(
probeVars,
// probe constants
in.admsProbeID_V_d_b,
in.admsProbeID_V_s_b,
in.admsProbeID_V_g_b,

// node constants
in.admsNodeID_d,
in.admsNodeID_g,
in.admsNodeID_s,
in.admsNodeID_b,
instanceStruct,
modelStruct,
 in.admsTemperature,
 in.adms_vt_nom,
 in.getDeviceOptions().gmin,
 d_staticContributions_dX,
 d_dynamicContributions_dX,
 in);


  // We now have the F and Q vector stuff, populate the dependencies:

    dfdp[in.admsNodeID_d+inst*(4+0)] += d_staticContributions_dX[in.admsNodeID_d];
    dqdp[in.admsNodeID_d+inst*(4+0)] += d_dynamicContributions_dX[in.admsNodeID_d];
    Findices[in.admsNodeID_d+inst*(4+0)] = in.li_d;
    Qindices[in.admsNodeID_d+inst*(4+0)] = in.li_d;
    dfdp[in.admsNodeID_g+inst*(4+0)] += d_staticContributions_dX[in.admsNodeID_g];
    dqdp[in.admsNodeID_g+inst*(4+0)] += d_dynamicContributions_dX[in.admsNodeID_g];
    Findices[in.admsNodeID_g+inst*(4+0)] = in.li_g;
    Qindices[in.admsNodeID_g+inst*(4+0)] = in.li_g;
    dfdp[in.admsNodeID_s+inst*(4+0)] += d_staticContributions_dX[in.admsNodeID_s];
    dqdp[in.admsNodeID_s+inst*(4+0)] += d_dynamicContributions_dX[in.admsNodeID_s];
    Findices[in.admsNodeID_s+inst*(4+0)] = in.li_s;
    Qindices[in.admsNodeID_s+inst*(4+0)] = in.li_s;
    dfdp[in.admsNodeID_b+inst*(4+0)] += d_staticContributions_dX[in.admsNodeID_b];
    dqdp[in.admsNodeID_b+inst*(4+0)] += d_dynamicContributions_dX[in.admsNodeID_b];
    Findices[in.admsNodeID_b+inst*(4+0)] = in.li_b;
    Qindices[in.admsNodeID_b+inst*(4+0)] = in.li_b;
}

}

#endif // Xyce_ADMS_SENSITIVITIES

} // namespace ADMSekv_va
} // namespace Device
} // namespace Xyce
